Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -764,68 +764,133 @@ def update_images():
|
|
764 |
def clear_textbox():
|
765 |
return ""
|
766 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
767 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
768 |
with gr.Row():
|
769 |
with gr.Column():
|
770 |
state = gr.State()
|
771 |
-
|
772 |
chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
|
773 |
choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
|
774 |
-
|
775 |
gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
776 |
-
|
777 |
-
chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!", placeholder="After Prompt,
|
778 |
-
chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
|
779 |
tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
|
780 |
retriever_button = gr.Button("Retriever")
|
781 |
-
|
|
|
|
|
|
|
782 |
gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
|
783 |
location_output = gr.HTML()
|
784 |
-
retriever_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
|
785 |
-
fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
|
786 |
-
fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder").then(
|
787 |
-
fn=clear_state_and_textbox, inputs=[], outputs=[chat_input]
|
788 |
-
)
|
789 |
-
|
790 |
-
bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
|
791 |
-
bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
|
792 |
-
chatbot.like(print_like_dislike, None, None)
|
793 |
-
clear_button = gr.Button("Clear")
|
794 |
-
clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
795 |
|
796 |
-
#
|
797 |
-
gr.
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
#
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
813 |
|
814 |
-
# with gr.Column():
|
815 |
-
# weather_output = gr.HTML(value=fetch_local_weather())
|
816 |
-
# news_output = gr.HTML(value=fetch_local_news())
|
817 |
-
# news_output = gr.HTML(value=fetch_local_events())
|
818 |
-
|
819 |
with gr.Column():
|
820 |
image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
821 |
image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
|
822 |
image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
|
823 |
|
824 |
refresh_button = gr.Button("Refresh Images")
|
825 |
-
refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
|
826 |
-
|
827 |
-
bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
|
828 |
-
|
829 |
demo.queue()
|
830 |
demo.launch(share=True)
|
831 |
|
|
|
764 |
def clear_textbox():
|
765 |
return ""
|
766 |
|
767 |
+
# with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
768 |
+
# with gr.Row():
|
769 |
+
# with gr.Column():
|
770 |
+
# state = gr.State()
|
771 |
+
|
772 |
+
# chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
|
773 |
+
# choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
|
774 |
+
|
775 |
+
# gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
776 |
+
|
777 |
+
# chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!", placeholder="After Prompt, click Retriever Only")
|
778 |
+
# chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
|
779 |
+
# tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
|
780 |
+
# retriever_button = gr.Button("Retriever")
|
781 |
+
|
782 |
+
# gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
|
783 |
+
# location_output = gr.HTML()
|
784 |
+
# retriever_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
|
785 |
+
# fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
|
786 |
+
# fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder").then(
|
787 |
+
# fn=clear_state_and_textbox, inputs=[], outputs=[chat_input]
|
788 |
+
# )
|
789 |
+
|
790 |
+
# bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
|
791 |
+
# bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
|
792 |
+
# chatbot.like(print_like_dislike, None, None)
|
793 |
+
# clear_button = gr.Button("Clear")
|
794 |
+
# clear_button.click(fn=clear_textbox, inputs=[], outputs=[chat_input])
|
795 |
+
|
796 |
+
# # New ASR Component with Whisper
|
797 |
+
# gr.Markdown("<h2>Hey Radar</h2>")
|
798 |
+
# audio_input_whisper = gr.Audio(sources=["microphone"], type='numpy')
|
799 |
+
# transcribe_button_whisper = gr.Button("Transcribe")
|
800 |
+
# transcribe_button_whisper.click(fn=transcribe_function_whisper, inputs=[audio_input_whisper], outputs=[chat_input], api_name="whisper_asr")
|
801 |
+
|
802 |
+
|
803 |
+
# # Streaming ASR component
|
804 |
+
# gr.Markdown("<h2>Streaming ASR</h2>")
|
805 |
+
# stream_audio_input = gr.Audio(sources=["microphone"], type='numpy', streaming=True)
|
806 |
+
# stream_transcription = gr.State(None) # Initialize stream state
|
807 |
+
# stream_audio_input.change(transcribe_function, inputs=[stream_transcription, stream_audio_input], outputs=[stream_transcription, chat_input],api_name="text_to_voice")
|
808 |
+
|
809 |
+
# # Add the clear button for ASR history
|
810 |
+
# clear_btn = gr.Button("Clear ASR ")
|
811 |
+
# # clear_btn.click(lambda: [None, ""], outputs=[stream_transcription, chat_input])
|
812 |
+
# clear_button.click(lambda:[None,None] ,outputs=[chat_input, state])
|
813 |
+
|
814 |
+
# # with gr.Column():
|
815 |
+
# # weather_output = gr.HTML(value=fetch_local_weather())
|
816 |
+
# # news_output = gr.HTML(value=fetch_local_news())
|
817 |
+
# # news_output = gr.HTML(value=fetch_local_events())
|
818 |
+
|
819 |
+
# with gr.Column():
|
820 |
+
# image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
821 |
+
# image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
|
822 |
+
# image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
|
823 |
+
|
824 |
+
# refresh_button = gr.Button("Refresh Images")
|
825 |
+
# refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
|
826 |
+
# # location_output = gr.HTML()
|
827 |
+
# bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
|
828 |
+
|
829 |
+
# demo.queue()
|
830 |
+
# demo.launch(share=True)
|
831 |
+
|
832 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
833 |
with gr.Row():
|
834 |
with gr.Column():
|
835 |
state = gr.State()
|
836 |
+
|
837 |
chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
|
838 |
choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
|
839 |
+
|
840 |
gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
841 |
+
|
842 |
+
chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!", placeholder="After Prompt,click Retriever Only")
|
|
|
843 |
tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
|
844 |
retriever_button = gr.Button("Retriever")
|
845 |
+
|
846 |
+
clear_button = gr.Button("Clear")
|
847 |
+
clear_button.click(lambda:[None,None] ,outputs=[chat_input, state])
|
848 |
+
|
849 |
gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
|
850 |
location_output = gr.HTML()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
851 |
|
852 |
+
# Define a single audio component
|
853 |
+
audio_output = gr.Audio(interactive=False, autoplay=True)
|
854 |
+
|
855 |
+
def stop_audio():
|
856 |
+
audio_output.stop()
|
857 |
+
return None
|
858 |
+
|
859 |
+
# Define the sequence of actions for the "Retriever" button
|
860 |
+
retriever_sequence = (
|
861 |
+
retriever_button.click(fn=stop_audio, inputs=[], outputs=[audio_output],api_name="Ask_Retriever")
|
862 |
+
.then(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input],api_name="voice_query")
|
863 |
+
.then(fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot, audio_output],api_name="generate_voice_response" )
|
864 |
+
.then(fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
|
865 |
+
.then(fn=clear_textbox, inputs=[], outputs=[chat_input])
|
866 |
+
)
|
867 |
+
|
868 |
+
# Link the "Enter" key (submit event) to the same sequence of actions
|
869 |
+
chat_input.submit(fn=stop_audio, inputs=[], outputs=[audio_output])
|
870 |
+
chat_input.submit(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input],api_name="voice_query").then(
|
871 |
+
fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot, audio_output], api_name="generate_voice_response"
|
872 |
+
).then(
|
873 |
+
fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder"
|
874 |
+
).then(
|
875 |
+
fn=clear_textbox, inputs=[], outputs=[chat_input]
|
876 |
+
)
|
877 |
+
|
878 |
+
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy', every=0.1)
|
879 |
+
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
|
880 |
+
|
881 |
+
with gr.Column():
|
882 |
+
weather_output = gr.HTML(value=fetch_local_weather())
|
883 |
+
news_output = gr.HTML(value=fetch_local_news())
|
884 |
+
events_output = gr.HTML(value=fetch_local_events())
|
885 |
|
|
|
|
|
|
|
|
|
|
|
886 |
with gr.Column():
|
887 |
image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
888 |
image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
|
889 |
image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
|
890 |
|
891 |
refresh_button = gr.Button("Refresh Images")
|
892 |
+
refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3], api_name="update_images")
|
893 |
+
|
|
|
|
|
894 |
demo.queue()
|
895 |
demo.launch(share=True)
|
896 |
|