Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -317,22 +317,11 @@ 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
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
return ""
|
326 |
-
|
327 |
-
def handle_single_chunk(history, choice, tts_choice, state):
|
328 |
-
full_text = process_single_audio_chunk(state)
|
329 |
-
if full_text:
|
330 |
-
history.append((full_text, None))
|
331 |
-
response, addresses = generate_answer(full_text, choice)
|
332 |
-
history[-1][1] = response
|
333 |
-
return history, None
|
334 |
-
return history, None
|
335 |
-
|
336 |
|
337 |
|
338 |
def print_like_dislike(x: gr.LikeData):
|
@@ -670,6 +659,59 @@ def update_images():
|
|
670 |
image_3 = generate_image(hardcoded_prompt_3)
|
671 |
return image_1, image_2, image_3
|
672 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
673 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
674 |
with gr.Row():
|
675 |
with gr.Column():
|
@@ -683,11 +725,14 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
683 |
chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!",placeholder="After Prompt,click Retriever Only")
|
684 |
chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
|
685 |
tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
|
686 |
-
|
687 |
-
|
|
|
|
|
|
|
688 |
gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
|
689 |
location_output = gr.HTML()
|
690 |
-
|
691 |
fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
|
692 |
fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
|
693 |
|
@@ -699,12 +744,12 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
699 |
|
700 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
701 |
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
|
702 |
-
|
703 |
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
|
709 |
|
710 |
with gr.Column():
|
@@ -716,8 +761,6 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
716 |
refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
|
717 |
location_output = gr.HTML()
|
718 |
bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
|
719 |
-
|
720 |
-
|
721 |
|
722 |
demo.queue()
|
723 |
demo.launch(share=True)
|
|
|
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 |
+
return gr.Textbox.update(value=transcription, interactive=True)
|
324 |
+
return chat_input
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
|
326 |
|
327 |
def print_like_dislike(x: gr.LikeData):
|
|
|
659 |
image_3 = generate_image(hardcoded_prompt_3)
|
660 |
return image_1, image_2, image_3
|
661 |
|
662 |
+
# with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
663 |
+
# with gr.Row():
|
664 |
+
# with gr.Column():
|
665 |
+
# state = gr.State()
|
666 |
+
|
667 |
+
# chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
|
668 |
+
# choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
|
669 |
+
|
670 |
+
# gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
671 |
+
|
672 |
+
# chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!",placeholder="After Prompt,click Retriever Only")
|
673 |
+
# chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
|
674 |
+
# tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
|
675 |
+
# retriver_button = gr.Button("Retriever")
|
676 |
+
|
677 |
+
# gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
|
678 |
+
# location_output = gr.HTML()
|
679 |
+
# retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
|
680 |
+
# fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
|
681 |
+
# fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
|
682 |
+
|
683 |
+
# bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
|
684 |
+
# bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
|
685 |
+
# chatbot.like(print_like_dislike, None, None)
|
686 |
+
# clear_button = gr.Button("Clear")
|
687 |
+
# clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
688 |
+
|
689 |
+
# audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
690 |
+
# audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
|
691 |
+
|
692 |
+
|
693 |
+
# # with gr.Column():
|
694 |
+
# # weather_output = gr.HTML(value=fetch_local_weather())
|
695 |
+
# # news_output = gr.HTML(value=fetch_local_news())
|
696 |
+
# # news_output = gr.HTML(value=fetch_local_events())
|
697 |
+
|
698 |
+
|
699 |
+
# with gr.Column():
|
700 |
+
# image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
701 |
+
# image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
|
702 |
+
# image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
|
703 |
+
|
704 |
+
# refresh_button = gr.Button("Refresh Images")
|
705 |
+
# refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
|
706 |
+
# location_output = gr.HTML()
|
707 |
+
# bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
|
708 |
+
|
709 |
+
|
710 |
+
|
711 |
+
# demo.queue()
|
712 |
+
# demo.launch(share=True)
|
713 |
+
|
714 |
+
|
715 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
716 |
with gr.Row():
|
717 |
with gr.Column():
|
|
|
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 |
|
|
|
744 |
|
745 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
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 |
+
weather_output = gr.HTML(value=fetch_local_weather())
|
751 |
+
news_output = gr.HTML(value=fetch_local_news())
|
752 |
+
news_output = gr.HTML(value=fetch_local_events())
|
753 |
|
754 |
|
755 |
with gr.Column():
|
|
|
761 |
refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
|
762 |
location_output = gr.HTML()
|
763 |
bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
|
|
|
|
|
764 |
|
765 |
demo.queue()
|
766 |
demo.launch(share=True)
|