Spaces:
Runtime error
Runtime error
Commit
·
b47f6e6
1
Parent(s):
6321098
updated submit button
Browse files
app.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
import time
|
2 |
import random
|
3 |
import gradio as gr
|
4 |
-
from transformers import pipeline
|
5 |
|
6 |
p = pipeline("automatic-speech-recognition")
|
7 |
|
8 |
def user(user_message, history):
|
9 |
return "", history + [[user_message, None]]
|
10 |
|
11 |
-
def transcribe(audio, state=""):
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
def bot(history):
|
17 |
bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
@@ -22,20 +22,29 @@ def bot(history):
|
|
22 |
yield history
|
23 |
|
24 |
with gr.Blocks() as demo:
|
25 |
-
chatbot = gr.Chatbot()
|
26 |
-
msg = gr.Textbox()
|
27 |
-
gr.
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
41 |
bot, chatbot, chatbot
|
|
|
1 |
import time
|
2 |
import random
|
3 |
import gradio as gr
|
4 |
+
# from transformers import pipeline
|
5 |
|
6 |
p = pipeline("automatic-speech-recognition")
|
7 |
|
8 |
def user(user_message, history):
|
9 |
return "", history + [[user_message, None]]
|
10 |
|
11 |
+
# def transcribe(audio, state=""):
|
12 |
+
# text = p(audio)["text"]
|
13 |
+
# state += text + " "
|
14 |
+
# return state, state
|
15 |
|
16 |
def bot(history):
|
17 |
bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
|
|
22 |
yield history
|
23 |
|
24 |
with gr.Blocks() as demo:
|
25 |
+
# chatbot = gr.Chatbot()
|
26 |
+
# msg = gr.Textbox()
|
27 |
+
chatbot = gr.Chatbot([], show_label=False, elem_id="chatbot").style(height=500)
|
28 |
+
|
29 |
+
with gr.Row():
|
30 |
+
with gr.Column(scale=0.85):
|
31 |
+
txt = gr.Textbox(
|
32 |
+
show_label=False,
|
33 |
+
placeholder="Type your response and press enter, or record your response",
|
34 |
+
).style(container=False)
|
35 |
+
with gr.Column(scale=0.15, min_width=0):
|
36 |
+
submit = gr.Button("Submit")
|
37 |
+
# gr.Interface(
|
38 |
+
# fn=transcribe,
|
39 |
+
# inputs=[
|
40 |
+
# gr.Audio(source="microphone", type="filepath", streaming=True),
|
41 |
+
# "state"
|
42 |
+
# ],
|
43 |
+
# outputs=[
|
44 |
+
# msg,
|
45 |
+
# "state"
|
46 |
+
# ],
|
47 |
+
# live=True)
|
48 |
|
49 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
50 |
bot, chatbot, chatbot
|