Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -640,6 +640,15 @@ def transcribe(audio_file):
|
|
640 |
print(f"Error in transcription: {str(e)}")
|
641 |
return f"Error in transcription: {str(e)}"
|
642 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
643 |
def vote(data: gr.LikeData):
|
644 |
if data.liked:
|
645 |
print(f"You upvoted this response: {data.value}")
|
@@ -699,7 +708,7 @@ with gr.Blocks() as demo:
|
|
699 |
with gr.Row():
|
700 |
with gr.Column(scale=1):
|
701 |
audio_input = gr.Audio(sources="microphone", type="filepath", label="Speak your query")
|
702 |
-
transcribe_button = gr.Button("Transcribe")
|
703 |
|
704 |
with gr.Column(scale=2):
|
705 |
chatbot = gr.Chatbot(
|
@@ -732,13 +741,13 @@ with gr.Blocks() as demo:
|
|
732 |
refresh_button = gr.Button("Refresh Document List")
|
733 |
|
734 |
update_output = gr.Textbox(label="Update Status")
|
735 |
-
delete_button = gr.Button("Delete Selected Documents")
|
736 |
|
737 |
transcribe_button.click(
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
)
|
742 |
|
743 |
submit_button.click(
|
744 |
respond,
|
|
|
640 |
print(f"Error in transcription: {str(e)}")
|
641 |
return f"Error in transcription: {str(e)}"
|
642 |
|
643 |
+
def transcribe_and_respond(audio_file, history, model, temperature, num_calls, use_web_search, document_selector):
|
644 |
+
transcription = transcribe(audio_file)
|
645 |
+
if transcription.startswith("Error in transcription:"):
|
646 |
+
return history + [(None, transcription)]
|
647 |
+
|
648 |
+
# Use the transcription as the query
|
649 |
+
new_history = respond(transcription, history, model, temperature, num_calls, use_web_search, document_selector)
|
650 |
+
return new_history
|
651 |
+
|
652 |
def vote(data: gr.LikeData):
|
653 |
if data.liked:
|
654 |
print(f"You upvoted this response: {data.value}")
|
|
|
708 |
with gr.Row():
|
709 |
with gr.Column(scale=1):
|
710 |
audio_input = gr.Audio(sources="microphone", type="filepath", label="Speak your query")
|
711 |
+
transcribe_button = gr.Button("Transcribe and Submit")
|
712 |
|
713 |
with gr.Column(scale=2):
|
714 |
chatbot = gr.Chatbot(
|
|
|
741 |
refresh_button = gr.Button("Refresh Document List")
|
742 |
|
743 |
update_output = gr.Textbox(label="Update Status")
|
744 |
+
delete_button = gr.Button("Delete Selected Documents")
|
745 |
|
746 |
transcribe_button.click(
|
747 |
+
transcribe_and_respond,
|
748 |
+
inputs=[audio_input, chatbot, model, temperature, num_calls, use_web_search, document_selector],
|
749 |
+
outputs=[chatbot]
|
750 |
+
)
|
751 |
|
752 |
submit_button.click(
|
753 |
respond,
|