ylacombe HF staff commited on
Commit
112a38f
1 Parent(s): fbacfdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -55,13 +55,13 @@ def transcribe(wav_path):
55
  # Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, & video). Plus shows support for streaming text.
56
 
57
 
58
- def add_text(history, text, agree):
59
  history = [] if history is None else history
60
  history = history + [(text, None)]
61
  return history, gr.update(value="", interactive=False)
62
 
63
 
64
- def add_file(history, file, agree):
65
  history = [] if history is None else history
66
  text = transcribe(
67
  file
@@ -72,7 +72,7 @@ def add_file(history, file, agree):
72
 
73
 
74
 
75
- def bot(history, agree, system_prompt=""):
76
  history = [] if history is None else history
77
 
78
  if system_prompt == "":
@@ -127,18 +127,22 @@ with gr.Blocks(title=title) as demo:
127
 
128
  with gr.Row():
129
  txt = gr.Textbox(
130
- scale=1,
131
  show_label=False,
132
  placeholder="Enter text and press enter, or speak to your microphone",
133
  container=False,
134
  )
135
- btn = gr.Audio(source="microphone", type="filepath", scale=2)
 
136
 
137
  with gr.Row():
138
  audio = gr.Audio(type="numpy", streaming=True, autoplay=True, label="Generated audio response", show_label=True)
139
 
140
  clear_btn = gr.ClearButton([chatbot, audio])
141
 
 
 
 
142
 
143
  txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
144
  bot, chatbot, chatbot
 
55
  # Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, & video). Plus shows support for streaming text.
56
 
57
 
58
+ def add_text(history, text):
59
  history = [] if history is None else history
60
  history = history + [(text, None)]
61
  return history, gr.update(value="", interactive=False)
62
 
63
 
64
+ def add_file(history, file):
65
  history = [] if history is None else history
66
  text = transcribe(
67
  file
 
72
 
73
 
74
 
75
+ def bot(history, system_prompt=""):
76
  history = [] if history is None else history
77
 
78
  if system_prompt == "":
 
127
 
128
  with gr.Row():
129
  txt = gr.Textbox(
130
+ scale=3,
131
  show_label=False,
132
  placeholder="Enter text and press enter, or speak to your microphone",
133
  container=False,
134
  )
135
+ txt_btn = gr.Button(value="Submit text",scale=1)
136
+ btn = gr.Audio(source="microphone", type="filepath", scale=4)
137
 
138
  with gr.Row():
139
  audio = gr.Audio(type="numpy", streaming=True, autoplay=True, label="Generated audio response", show_label=True)
140
 
141
  clear_btn = gr.ClearButton([chatbot, audio])
142
 
143
+ txt_msg = txt_btn.click(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
144
+ bot, chatbot, chatbot
145
+ ).then(generate_speech, chatbot, audio)
146
 
147
  txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
148
  bot, chatbot, chatbot