Spaces:
Runtime error
Runtime error
Commit
·
1b44681
1
Parent(s):
aa5cf68
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import time
|
2 |
import random
|
3 |
import gradio as gr
|
4 |
-
|
5 |
|
6 |
-
|
7 |
|
8 |
def user(user_message, history):
|
9 |
return "", history + [[user_message, None]]
|
@@ -76,17 +76,16 @@ with gr.Blocks(css=css) as demo:
|
|
76 |
|
77 |
# with gr.Row():
|
78 |
with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
|
79 |
-
with gr.Column(scale=0.
|
80 |
txt = gr.Textbox(
|
81 |
show_label=False,
|
82 |
placeholder="Type your response and press enter, or record your response",
|
83 |
).style(container=False)
|
84 |
with gr.Column(scale=0.15, min_width=0):
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
outputs="text")
|
90 |
# gr.Interface(
|
91 |
# fn=transcribe,
|
92 |
# inputs=[
|
@@ -99,11 +98,13 @@ with gr.Blocks(css=css) as demo:
|
|
99 |
# ],
|
100 |
# live=True)
|
101 |
|
102 |
-
|
|
|
|
|
103 |
txt.submit(user, [txt, chatbot], [txt, chatbot], queue=False).then(
|
104 |
bot, chatbot, chatbot
|
105 |
)
|
106 |
-
|
107 |
bot, chatbot, chatbot
|
108 |
)
|
109 |
|
|
|
1 |
import time
|
2 |
import random
|
3 |
import gradio as gr
|
4 |
+
from transformers import pipeline
|
5 |
|
6 |
+
p = pipeline("automatic-speech-recognition", "facebook/wav2vec2-base-960h")
|
7 |
|
8 |
def user(user_message, history):
|
9 |
return "", history + [[user_message, None]]
|
|
|
76 |
|
77 |
# with gr.Row():
|
78 |
with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
|
79 |
+
with gr.Column(scale=0.70):
|
80 |
txt = gr.Textbox(
|
81 |
show_label=False,
|
82 |
placeholder="Type your response and press enter, or record your response",
|
83 |
).style(container=False)
|
84 |
with gr.Column(scale=0.15, min_width=0):
|
85 |
+
record = gr.Audio(source="microphone", type="filepath", show_label=False)
|
86 |
+
with gr.Column(scale=0.15, min_width=0):
|
87 |
+
speech = gr.Button("Submit")
|
88 |
+
|
|
|
89 |
# gr.Interface(
|
90 |
# fn=transcribe,
|
91 |
# inputs=[
|
|
|
98 |
# ],
|
99 |
# live=True)
|
100 |
|
101 |
+
send = gr.Button("Send")
|
102 |
+
|
103 |
+
speech.click(transcribe, inputs=record, outputs=txt)
|
104 |
txt.submit(user, [txt, chatbot], [txt, chatbot], queue=False).then(
|
105 |
bot, chatbot, chatbot
|
106 |
)
|
107 |
+
send.click(user, [txt, chatbot], [txt, chatbot], queue=False).then(
|
108 |
bot, chatbot, chatbot
|
109 |
)
|
110 |
|