Pijush2023 commited on
Commit
446cb0c
·
verified ·
1 Parent(s): 92d6b3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -65
app.py CHANGED
@@ -317,13 +317,6 @@ 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, 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):
@@ -661,59 +654,6 @@ def update_images():
661
  image_3 = generate_image(hardcoded_prompt_3)
662
  return image_1, image_2, image_3
663
 
664
- # with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
665
- # with gr.Row():
666
- # with gr.Column():
667
- # state = gr.State()
668
-
669
- # chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
670
- # choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
671
-
672
- # gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
673
-
674
- # chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!",placeholder="After Prompt,click Retriever Only")
675
- # chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
676
- # tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
677
- # retriver_button = gr.Button("Retriever")
678
-
679
- # gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
680
- # location_output = gr.HTML()
681
- # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
682
- # fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
683
- # fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
684
-
685
- # bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
686
- # bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
687
- # chatbot.like(print_like_dislike, None, None)
688
- # clear_button = gr.Button("Clear")
689
- # clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
690
-
691
- # audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
692
- # audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
693
-
694
-
695
- # # with gr.Column():
696
- # # weather_output = gr.HTML(value=fetch_local_weather())
697
- # # news_output = gr.HTML(value=fetch_local_news())
698
- # # news_output = gr.HTML(value=fetch_local_events())
699
-
700
-
701
- # with gr.Column():
702
- # image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
703
- # image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
704
- # image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
705
-
706
- # refresh_button = gr.Button("Refresh Images")
707
- # refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
708
- # location_output = gr.HTML()
709
- # bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
710
-
711
-
712
-
713
- # demo.queue()
714
- # demo.launch(share=True)
715
-
716
-
717
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
718
  with gr.Row():
719
  with gr.Column():
@@ -724,26 +664,33 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
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)
@@ -753,6 +700,11 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
753
  refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
754
  location_output = gr.HTML()
755
  bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
 
 
756
 
757
  demo.queue()
758
  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
 
321
 
322
  def print_like_dislike(x: gr.LikeData):
 
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():
 
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=False, type='numpy')
685
  audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
686
+
687
 
688
  # with gr.Column():
689
  # weather_output = gr.HTML(value=fetch_local_weather())
690
  # news_output = gr.HTML(value=fetch_local_news())
691
  # news_output = gr.HTML(value=fetch_local_events())
692
 
693
+
694
  with gr.Column():
695
  image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
696
  image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
 
700
  refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
701
  location_output = gr.HTML()
702
  bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
703
+
704
+
705
 
706
  demo.queue()
707
  demo.launch(share=True)
708
+
709
+
710
+