Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -496,8 +496,10 @@ def transcribe_function(stream, new_chunk):
|
|
496 |
stream = y # Always start with fresh stream
|
497 |
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
498 |
full_text = result.get("text", "")
|
499 |
-
return stream, full_text
|
500 |
|
|
|
|
|
501 |
|
502 |
|
503 |
def update_map_with_response(history):
|
@@ -712,8 +714,16 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
712 |
|
713 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
714 |
# audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
|
715 |
-
|
716 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
717 |
|
718 |
|
719 |
|
|
|
496 |
stream = y # Always start with fresh stream
|
497 |
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
498 |
full_text = result.get("text", "")
|
499 |
+
return stream, full_text # Return the transcribed text
|
500 |
|
501 |
+
def transfer_text(transcribed_text):
|
502 |
+
return transcribed_text, gr.Textbox.update(value=transcribed_text)
|
503 |
|
504 |
|
505 |
def update_map_with_response(history):
|
|
|
714 |
|
715 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
716 |
# audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
|
717 |
+
transcribed_text = gr.Textbox(interactive=False, show_label=False)
|
718 |
+
|
719 |
+
audio_input.stream(transcribe_function, inputs=[None, audio_input], outputs=[None, transcribed_text])
|
720 |
+
|
721 |
+
transfer_button = gr.Button("Transfer to Input Prompt")
|
722 |
+
transfer_button.click(fn=transfer_text, inputs=[transcribed_text], outputs=[transcribed_text, chat_input])
|
723 |
+
|
724 |
+
demo.append(audio_input)
|
725 |
+
demo.append(transcribed_text)
|
726 |
+
demo.append(transfer_button)
|
727 |
|
728 |
|
729 |
|