OuroborosM commited on
Commit
b87aac4
·
1 Parent(s): 83827d3

link with chatbot

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -333,8 +333,9 @@ def speech_to_text(Filename_Audio_input_single):
333
  "Content-Type": "audio/wav",}
334
 
335
  response = requests.post(endpoint, headers=headers, data=open(Filename_Audio_input_single, "rb"))
336
- print("Speech to Text: ", response.text)
337
- text_from_audio = response.txt
 
338
  return text_from_audio
339
  except requests.exceptions.RequestException as e:
340
  print(f"Error speech_to_text: {e}")
@@ -895,6 +896,11 @@ def ClearAudio():
895
 
896
  return None
897
 
 
 
 
 
 
898
  with gr.Blocks() as demo:
899
  # gr.Markdown("Start typing below and then click **SUBMIT** to see the output.")
900
  # main = gr.ChatInterface(
@@ -980,7 +986,7 @@ with gr.Blocks() as demo:
980
  upload_button.upload(func_upload_file, [upload_button, chatbot], chatbot)
981
  agentchoice.change(SetAgent, agentchoice, None)
982
  frash_logs.click(read_logs, None, logs)
983
- voice_input.stop_recording(speech_to_text, voice_input, None)
984
  # voice_output.end(ClearAudio, None, voice_output)
985
  # def clear_voice():
986
  # print("clear audio ...")
 
333
  "Content-Type": "audio/wav",}
334
 
335
  response = requests.post(endpoint, headers=headers, data=open(Filename_Audio_input_single, "rb"))
336
+ print("Speech to Text Raw: ", response.text)
337
+ text_from_audio = response.text['DisplayText']
338
+ print("Speech to Text: ", text_from_audio)
339
  return text_from_audio
340
  except requests.exceptions.RequestException as e:
341
  print(f"Error speech_to_text: {e}")
 
896
 
897
  return None
898
 
899
+ def SingleTalk(WavFile, history5):
900
+ ConvertText = speech_to_text(WavFile)
901
+ history5 = history5 + [(ConvertText, None)]
902
+ yield history5
903
+
904
  with gr.Blocks() as demo:
905
  # gr.Markdown("Start typing below and then click **SUBMIT** to see the output.")
906
  # main = gr.ChatInterface(
 
986
  upload_button.upload(func_upload_file, [upload_button, chatbot], chatbot)
987
  agentchoice.change(SetAgent, agentchoice, None)
988
  frash_logs.click(read_logs, None, logs)
989
+ voice_input.stop_recording(SingleTalk, [voice_input, chatbot], [voice_output, chatbot])
990
  # voice_output.end(ClearAudio, None, voice_output)
991
  # def clear_voice():
992
  # print("clear audio ...")