GreenRaptor commited on
Commit
aa5cf68
·
1 Parent(s): 03de940

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -13,6 +13,10 @@ def user(user_message, history):
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"])
18
  history[-1][1] = ""
@@ -72,15 +76,17 @@ with gr.Blocks(css=css) as demo:
72
 
73
  # with gr.Row():
74
  with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
75
- with gr.Column(scale=0.80):
76
  txt = gr.Textbox(
77
  show_label=False,
78
  placeholder="Type your response and press enter, or record your response",
79
  ).style(container=False)
80
- with gr.Column(scale=0.10, min_width=0):
81
- record = gr.Audio(source="microphone", type="filepath", streaming=True)
82
- with gr.Column(scale=0.10, min_width=0):
83
- submit = gr.Button("Submit")
 
 
84
  # gr.Interface(
85
  # fn=transcribe,
86
  # inputs=[
@@ -92,7 +98,8 @@ with gr.Blocks(css=css) as demo:
92
  # "state"
93
  # ],
94
  # live=True)
95
-
 
96
  txt.submit(user, [txt, chatbot], [txt, chatbot], queue=False).then(
97
  bot, chatbot, chatbot
98
  )
 
13
  # state += text + " "
14
  # return state, state
15
 
16
+ def transcribe(audio):
17
+ text = p(audio)["text"]
18
+ return text
19
+
20
  def bot(history):
21
  bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
22
  history[-1][1] = ""
 
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.85):
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
+ gr.Interface(
87
+ fn=transcribe,
88
+ inputs=gr.Audio(source="microphone", type="filepath", show_label=False),
89
+ outputs="text")
90
  # gr.Interface(
91
  # fn=transcribe,
92
  # inputs=[
 
98
  # "state"
99
  # ],
100
  # live=True)
101
+
102
+ submit = gr.Button("Submit")
103
  txt.submit(user, [txt, chatbot], [txt, chatbot], queue=False).then(
104
  bot, chatbot, chatbot
105
  )