Pijush2023 commited on
Commit
e692155
·
verified ·
1 Parent(s): b0c754f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -10
app.py CHANGED
@@ -809,6 +809,50 @@ def update_images():
809
  # demo.queue()
810
  # demo.launch(share=True)
811
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
812
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
813
  with gr.Row():
814
  with gr.Column():
@@ -823,12 +867,12 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
823
  chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
824
  tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
825
  retriver_button = gr.Button("Retriever")
826
- # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
827
- # fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever")
828
  retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
829
  fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
830
- fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
831
- bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
 
832
  bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
833
  chatbot.like(print_like_dislike, None, None)
834
  clear_button = gr.Button("Clear")
@@ -838,9 +882,7 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
838
  audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
839
 
840
  gr.Markdown("<h1 style='color: red;'>Map</h1>", elem_id="location-markdown")
841
- location_output = gr.HTML()
842
- bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
843
-
844
  with gr.Column():
845
  image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
846
  image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
@@ -848,8 +890,7 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
848
 
849
  refresh_button = gr.Button("Refresh Images")
850
  refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
851
-
 
852
  demo.queue()
853
  demo.launch(share=True)
854
-
855
-
 
809
  # demo.queue()
810
  # demo.launch(share=True)
811
 
812
+ # with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
813
+ # with gr.Row():
814
+ # with gr.Column():
815
+ # state = gr.State()
816
+
817
+ # chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
818
+ # choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
819
+
820
+ # gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
821
+
822
+ # chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
823
+ # chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
824
+ # tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
825
+ # retriver_button = gr.Button("Retriever")
826
+ # # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
827
+ # # fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever")
828
+ # location_output = gr.HTML()
829
+ # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
830
+ # fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
831
+ # fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
832
+ # bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
833
+ # bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
834
+ # chatbot.like(print_like_dislike, None, None)
835
+ # clear_button = gr.Button("Clear")
836
+ # clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
837
+
838
+ # audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
839
+ # audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
840
+
841
+ # gr.Markdown("<h1 style='color: red;'>Map</h1>", elem_id="location-markdown")
842
+ # location_output = gr.HTML()
843
+ # bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
844
+
845
+ # with gr.Column():
846
+ # image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
847
+ # image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
848
+ # image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
849
+
850
+ # refresh_button = gr.Button("Refresh Images")
851
+ # refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
852
+
853
+ # demo.queue()
854
+ # demo.launch(share=True)
855
+
856
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
857
  with gr.Row():
858
  with gr.Column():
 
867
  chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
868
  tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
869
  retriver_button = gr.Button("Retriever")
870
+ location_output = gr.HTML() # Initialize location_output here
 
871
  retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
872
  fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
873
+ fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
874
+
875
+ bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="generate_voice_response")
876
  bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
877
  chatbot.like(print_like_dislike, None, None)
878
  clear_button = gr.Button("Clear")
 
882
  audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
883
 
884
  gr.Markdown("<h1 style='color: red;'>Map</h1>", elem_id="location-markdown")
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)
 
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])
893
+ location_output = gr.HTML()
894
+ bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
895
  demo.queue()
896
  demo.launch(share=True)