Pijush2023 commited on
Commit
81a2658
·
verified ·
1 Parent(s): 06d41a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -625,6 +625,26 @@ pipe_asr = pipeline("automatic-speech-recognition", model=model, tokenizer=proce
625
 
626
  base_audio_drive = "/data/audio"
627
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628
  def transcribe_function(stream, new_chunk):
629
  try:
630
  sr, y = new_chunk[0], new_chunk[1]
@@ -836,8 +856,9 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
836
  chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input],api_name="voice_query")
837
  tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
838
  retriver_button = gr.Button("Retriver")
 
839
  retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
840
- fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot],api_name="Ask_Retriever")
841
  #gr.Audio(interactive=False, autoplay=True)]
842
 
843
  # voice_response_button = gr.Button("Voice Response")
 
625
 
626
  base_audio_drive = "/data/audio"
627
 
628
+ # def transcribe_function(stream, new_chunk):
629
+ # try:
630
+ # sr, y = new_chunk[0], new_chunk[1]
631
+ # except TypeError:
632
+ # print(f"Error chunk structure: {type(new_chunk)}, content: {new_chunk}")
633
+ # return stream, "", None
634
+
635
+ # y = y.astype(np.float32) / np.max(np.abs(y))
636
+
637
+ # if stream is not None:
638
+ # stream = np.concatenate([stream, y])
639
+ # else:
640
+ # stream = y
641
+
642
+ # result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
643
+
644
+ # full_text = result.get("text")
645
+
646
+ # return stream, full_text, result
647
+
648
  def transcribe_function(stream, new_chunk):
649
  try:
650
  sr, y = new_chunk[0], new_chunk[1]
 
856
  chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input],api_name="voice_query")
857
  tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
858
  retriver_button = gr.Button("Retriver")
859
+ # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot],api_name="Ask_Retriever")
860
  retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
861
+ fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot], api_name="Ask_Retriever")
862
  #gr.Audio(interactive=False, autoplay=True)]
863
 
864
  # voice_response_button = gr.Button("Voice Response")