Pijush2023 commited on
Commit
b253be3
·
verified ·
1 Parent(s): e3a450b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +72 -40
app.py CHANGED
@@ -654,59 +654,91 @@ def update_images():
654
  image_3 = generate_image(hardcoded_prompt_3)
655
  return image_1, image_2, image_3
656
 
657
- with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
658
- with gr.Row():
659
- with gr.Column():
660
- state = gr.State()
661
 
662
- chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
663
- choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
664
 
665
- gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
666
 
667
- chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!",placeholder="After Prompt,click Retriever Only")
668
- chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
669
- tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
670
- retriver_button = gr.Button("Retriever")
671
 
672
- gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
673
- location_output = gr.HTML()
674
- retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
675
- fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
676
- fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
677
 
678
- bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
679
- bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
680
- chatbot.like(print_like_dislike, None, None)
681
- clear_button = gr.Button("Clear")
682
- clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
683
 
684
- audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
685
- audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
686
 
687
- send_chunk_button = gr.Button("Send chunk")
688
- send_chunk_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="voice_query")
689
 
690
 
691
- # with gr.Column():
692
- # weather_output = gr.HTML(value=fetch_local_weather())
693
- # news_output = gr.HTML(value=fetch_local_news())
694
- # news_output = gr.HTML(value=fetch_local_events())
695
 
696
 
697
- with gr.Column():
698
- image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
699
- image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
700
- image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
701
-
702
- refresh_button = gr.Button("Refresh Images")
703
- refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
704
- location_output = gr.HTML()
705
- bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
706
 
707
 
708
 
709
- demo.queue()
710
- demo.launch(share=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
711
 
712
 
 
654
  image_3 = generate_image(hardcoded_prompt_3)
655
  return image_1, image_2, image_3
656
 
657
+ # with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
658
+ # with gr.Row():
659
+ # with gr.Column():
660
+ # state = gr.State()
661
 
662
+ # chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
663
+ # choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
664
 
665
+ # gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
666
 
667
+ # chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!",placeholder="After Prompt,click Retriever Only")
668
+ # chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
669
+ # tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
670
+ # retriver_button = gr.Button("Retriever")
671
 
672
+ # gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
673
+ # location_output = gr.HTML()
674
+ # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
675
+ # fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
676
+ # fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
677
 
678
+ # bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
679
+ # bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
680
+ # chatbot.like(print_like_dislike, None, None)
681
+ # clear_button = gr.Button("Clear")
682
+ # clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
683
 
684
+ # audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
685
+ # audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
686
 
687
+ # # send_chunk_button = gr.Button("Send chunk")
688
+ # # send_chunk_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input], api_name="voice_query")
689
 
690
 
691
+ # # with gr.Column():
692
+ # # weather_output = gr.HTML(value=fetch_local_weather())
693
+ # # news_output = gr.HTML(value=fetch_local_news())
694
+ # # news_output = gr.HTML(value=fetch_local_events())
695
 
696
 
697
+ # with gr.Column():
698
+ # image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
699
+ # image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
700
+ # image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
701
+
702
+ # refresh_button = gr.Button("Refresh Images")
703
+ # refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
704
+ # location_output = gr.HTML()
705
+ # bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
706
 
707
 
708
 
709
+ # demo.queue()
710
+ # demo.launch(share=True)
711
+
712
+
713
+ with gr.Column():
714
+ state = gr.State()
715
+ chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
716
+ choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
717
+
718
+ gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
719
+
720
+ chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!",placeholder="After Prompt,click Retriever Only")
721
+ chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
722
+ tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
723
+ retriver_button = gr.Button("Retriever")
724
+
725
+ gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
726
+ location_output = gr.HTML()
727
+ retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
728
+ fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
729
+ fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
730
+
731
+ bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
732
+ bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
733
+ chatbot.like(print_like_dislike, None, None)
734
+ clear_button = gr.Button("Clear")
735
+ clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
736
+
737
+ audio_input = gr.Audio(sources=["microphone"], streaming=False, type='numpy')
738
+ audio_input.change(fn=transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
739
+
740
+ send_chunk_button = gr.Button("Send chunk")
741
+ send_chunk_button.click(fn=lambda state: state[1], inputs=[state], outputs=chat_input)
742
+
743
 
744