Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -317,11 +317,13 @@ def add_message(history, message):
|
|
317 |
history.append((message, None))
|
318 |
return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|
319 |
|
320 |
-
def send_chunk(state, chat_input):
|
321 |
if state:
|
322 |
transcription = state
|
323 |
-
|
324 |
-
|
|
|
|
|
325 |
|
326 |
|
327 |
def print_like_dislike(x: gr.LikeData):
|
@@ -722,36 +724,26 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
722 |
|
723 |
gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
724 |
|
725 |
-
chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!",placeholder="After Prompt,click Retriever Only")
|
726 |
-
chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
|
727 |
tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
|
728 |
retriever_button = gr.Button("Retriever")
|
729 |
send_chunk_button = gr.Button("Send Chunk")
|
730 |
|
731 |
-
send_chunk_button.click(fn=send_chunk, inputs=[state, chat_input], outputs=chat_input)
|
732 |
-
|
733 |
-
gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
|
734 |
-
location_output = gr.HTML()
|
735 |
-
retriever_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
|
736 |
fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
|
737 |
fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
|
738 |
-
|
739 |
-
bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
|
740 |
-
bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
|
741 |
-
chatbot.like(print_like_dislike, None, None)
|
742 |
clear_button = gr.Button("Clear")
|
743 |
clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
744 |
|
745 |
-
audio_input = gr.Audio(sources=["microphone"], streaming=
|
746 |
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
|
747 |
-
|
748 |
|
749 |
-
with gr.Column():
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
|
754 |
-
|
755 |
with gr.Column():
|
756 |
image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
757 |
image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
|
|
|
317 |
history.append((message, None))
|
318 |
return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|
319 |
|
320 |
+
def send_chunk(state, chat_input, chatbot):
|
321 |
if state:
|
322 |
transcription = state
|
323 |
+
chat_input = transcription
|
324 |
+
chatbot.append((transcription, None))
|
325 |
+
return chatbot, chat_input, gr.update(visible=False)
|
326 |
+
return chatbot, chat_input, gr.update(visible=False)
|
327 |
|
328 |
|
329 |
def print_like_dislike(x: gr.LikeData):
|
|
|
724 |
|
725 |
gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
726 |
|
727 |
+
chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!", placeholder="After Prompt, click Retriever Only")
|
|
|
728 |
tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
|
729 |
retriever_button = gr.Button("Retriever")
|
730 |
send_chunk_button = gr.Button("Send Chunk")
|
731 |
|
732 |
+
send_chunk_button.click(fn=send_chunk, inputs=[state, chat_input, chatbot], outputs=[chatbot, chat_input, audio_input]).then(
|
|
|
|
|
|
|
|
|
733 |
fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
|
734 |
fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
|
735 |
+
|
|
|
|
|
|
|
736 |
clear_button = gr.Button("Clear")
|
737 |
clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
738 |
|
739 |
+
audio_input = gr.Audio(sources=["microphone"], streaming=False, type='numpy')
|
740 |
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
|
|
|
741 |
|
742 |
+
# with gr.Column():
|
743 |
+
# weather_output = gr.HTML(value=fetch_local_weather())
|
744 |
+
# news_output = gr.HTML(value=fetch_local_news())
|
745 |
+
# news_output = gr.HTML(value=fetch_local_events())
|
746 |
|
|
|
747 |
with gr.Column():
|
748 |
image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
749 |
image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
|