Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -289,28 +289,7 @@ def generate_answer(message, choice):
|
|
289 |
addresses = extract_addresses(response['output'])
|
290 |
return response['output'], addresses
|
291 |
|
292 |
-
|
293 |
-
# if not history:
|
294 |
-
# return history
|
295 |
-
# response, addresses = generate_answer(history[-1][0], choice)
|
296 |
-
# history[-1][1] = ""
|
297 |
-
|
298 |
-
# with concurrent.futures.ThreadPoolExecutor() as executor:
|
299 |
-
# if tts_choice == "Alpha":
|
300 |
-
# audio_future = executor.submit(generate_audio_elevenlabs, response)
|
301 |
-
# elif tts_choice == "Beta":
|
302 |
-
# audio_future = executor.submit(generate_audio_parler_tts, response)
|
303 |
-
# elif tts_choice == "Gamma":
|
304 |
-
# audio_future = executor.submit(generate_audio_mars5, response)
|
305 |
-
|
306 |
-
|
307 |
-
# for character in response:
|
308 |
-
# history[-1][1] += character
|
309 |
-
# time.sleep(0.05)
|
310 |
-
# yield history, None
|
311 |
-
|
312 |
-
# audio_path = audio_future.result()
|
313 |
-
# yield history, audio_path
|
314 |
|
315 |
def bot(history, choice, tts_choice, state):
|
316 |
if not history:
|
@@ -340,21 +319,7 @@ def add_message(history, message):
|
|
340 |
|
341 |
|
342 |
|
343 |
-
|
344 |
-
# if not history:
|
345 |
-
# return None
|
346 |
-
|
347 |
-
# response = history[-1][1]
|
348 |
-
# with concurrent.futures.ThreadPoolExecutor() as executor:
|
349 |
-
# if tts_choice == "Alpha":
|
350 |
-
# audio_future = executor.submit(generate_audio_elevenlabs, response)
|
351 |
-
# elif tts_choice == "Beta":
|
352 |
-
# audio_future = executor.submit(generate_audio_parler_tts, response)
|
353 |
-
# elif tts_choice == "Gamma":
|
354 |
-
# audio_future = executor.submit(generate_audio_mars5, response)
|
355 |
-
|
356 |
-
# audio_path = audio_future.result()
|
357 |
-
# return audio_path
|
358 |
|
359 |
def print_like_dislike(x: gr.LikeData):
|
360 |
print(x.index, x.value, x.liked)
|
@@ -380,26 +345,7 @@ def extract_addresses(response):
|
|
380 |
|
381 |
all_addresses = []
|
382 |
|
383 |
-
|
384 |
-
# global all_addresses
|
385 |
-
# all_addresses.extend(location_names)
|
386 |
-
|
387 |
-
# api_key = os.environ['GOOGLEMAPS_API_KEY']
|
388 |
-
# gmaps = GoogleMapsClient(key=api_key)
|
389 |
-
|
390 |
-
# m = folium.Map(location=[33.5175,-86.809444], zoom_start=16)
|
391 |
-
|
392 |
-
# for location_name in all_addresses:
|
393 |
-
# geocode_result = gmaps.geocode(location_name)
|
394 |
-
# if geocode_result:
|
395 |
-
# location = geocode_result[0]['geometry']['location']
|
396 |
-
# folium.Marker(
|
397 |
-
# [location['lat'], 'lng'],
|
398 |
-
# tooltip=f"{geocode_result[0]['formatted_address']}"
|
399 |
-
# ).add_to(m)
|
400 |
-
|
401 |
-
# map_html = m._repr_html_()
|
402 |
-
# return map_html
|
403 |
|
404 |
def generate_map(location_names):
|
405 |
global all_addresses
|
@@ -709,150 +655,6 @@ def update_images():
|
|
709 |
image_3 = generate_image(hardcoded_prompt_3)
|
710 |
return image_1, image_2, image_3
|
711 |
|
712 |
-
# with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
713 |
-
# with gr.Row():
|
714 |
-
# with gr.Column():
|
715 |
-
# state = gr.State()
|
716 |
-
|
717 |
-
# chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
|
718 |
-
# choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
|
719 |
-
|
720 |
-
# gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
721 |
-
|
722 |
-
# chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
|
723 |
-
# chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input],api_name="voice_query")
|
724 |
-
# tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
|
725 |
-
# retriver_button = gr.Button("Retriver")
|
726 |
-
# # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot],api_name="Ask_Retriever")
|
727 |
-
# # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
|
728 |
-
# # fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot], api_name="Ask_Retriever")
|
729 |
-
# retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
|
730 |
-
# fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot], api_name="Ask_Retriever")
|
731 |
-
|
732 |
-
# #gr.Audio(interactive=False, autoplay=True)]
|
733 |
-
|
734 |
-
# # voice_response_button = gr.Button("Voice Response")
|
735 |
-
# # voice_response_button.click(fn=generate_voice_response, inputs=[chatbot, tts_choice], outputs=[gr.Audio(interactive=False, autoplay=True)],api_name="generate_voice_response")
|
736 |
-
|
737 |
-
# bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot, gr.Audio(interactive=False, autoplay=True)],api_name="generate_voice_response")
|
738 |
-
# # bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
|
739 |
-
# bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
|
740 |
-
# chatbot.like(print_like_dislike, None, None)
|
741 |
-
# clear_button = gr.Button("Clear")
|
742 |
-
# clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
743 |
-
|
744 |
-
# audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
745 |
-
# audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
|
746 |
-
|
747 |
-
|
748 |
-
# gr.Markdown("<h1 style='color: red;'>Map</h1>", elem_id="location-markdown")
|
749 |
-
# location_output = gr.HTML()
|
750 |
-
# bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output],api_name="map_finder")
|
751 |
-
|
752 |
-
|
753 |
-
# # with gr.Column():
|
754 |
-
# # weather_output = gr.HTML(value=fetch_local_weather())
|
755 |
-
# # news_output = gr.HTML(value=fetch_local_news())
|
756 |
-
# # news_output = gr.HTML(value=fetch_local_events())
|
757 |
-
|
758 |
-
# with gr.Column():
|
759 |
-
# image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
760 |
-
# image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
|
761 |
-
# image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
|
762 |
-
|
763 |
-
# refresh_button = gr.Button("Refresh Images")
|
764 |
-
# refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
|
765 |
-
|
766 |
-
# demo.queue()
|
767 |
-
# demo.launch(share=True)
|
768 |
-
|
769 |
-
# with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
770 |
-
# with gr.Row():
|
771 |
-
# with gr.Column():
|
772 |
-
# state = gr.State()
|
773 |
-
|
774 |
-
# chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
|
775 |
-
# choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
|
776 |
-
|
777 |
-
# gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
778 |
-
|
779 |
-
# chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
|
780 |
-
# chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
|
781 |
-
# tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
|
782 |
-
# retriver_button = gr.Button("Retriever")
|
783 |
-
# retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
|
784 |
-
# fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever")
|
785 |
-
|
786 |
-
# # bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot, gr.Audio(interactive=False, autoplay=True], api_name="generate_voice_response")
|
787 |
-
# bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
|
788 |
-
|
789 |
-
# bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
|
790 |
-
# chatbot.like(print_like_dislike, None, None)
|
791 |
-
# clear_button = gr.Button("Clear")
|
792 |
-
# clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
793 |
-
|
794 |
-
# audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
795 |
-
# audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
|
796 |
-
|
797 |
-
# gr.Markdown("<h1 style='color: red;'>Map</h1>", elem_id="location-markdown")
|
798 |
-
# location_output = gr.HTML()
|
799 |
-
# bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output], api_name="map_finder")
|
800 |
-
|
801 |
-
# with gr.Column():
|
802 |
-
# image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
803 |
-
# image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
|
804 |
-
# image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
|
805 |
-
|
806 |
-
# refresh_button = gr.Button("Refresh Images")
|
807 |
-
# refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
|
808 |
-
|
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,12 +669,12 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
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 |
-
|
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
|
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")
|
@@ -881,7 +683,15 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
881 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
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="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
885 |
|
886 |
with gr.Column():
|
887 |
image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
|
|
289 |
addresses = extract_addresses(response['output'])
|
290 |
return response['output'], addresses
|
291 |
|
292 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
|
294 |
def bot(history, choice, tts_choice, state):
|
295 |
if not history:
|
|
|
319 |
|
320 |
|
321 |
|
322 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
|
324 |
def print_like_dislike(x: gr.LikeData):
|
325 |
print(x.index, x.value, x.liked)
|
|
|
345 |
|
346 |
all_addresses = []
|
347 |
|
348 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
|
350 |
def generate_map(location_names):
|
351 |
global all_addresses
|
|
|
655 |
image_3 = generate_image(hardcoded_prompt_3)
|
656 |
return image_1, image_2, image_3
|
657 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
658 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
659 |
with gr.Row():
|
660 |
with gr.Column():
|
|
|
669 |
chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], api_name="voice_query")
|
670 |
tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
|
671 |
retriver_button = gr.Button("Retriever")
|
672 |
+
|
673 |
retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
|
674 |
fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot, gr.Audio(interactive=False, autoplay=True)], api_name="Ask_Retriever").then(
|
675 |
fn=show_map_if_details, inputs=[chatbot, choice], outputs=[location_output, location_output], api_name="map_finder")
|
676 |
|
677 |
+
bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot], api_name="generate_voice_response")
|
678 |
bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
|
679 |
chatbot.like(print_like_dislike, None, None)
|
680 |
clear_button = gr.Button("Clear")
|
|
|
683 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
684 |
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
|
685 |
|
686 |
+
gr.Markdown("<h1 style='color: red;'>Radar Map</h1>", elem_id="Map-Radar")
|
687 |
+
location_output = gr.HTML() # Initialize location_output here
|
688 |
+
|
689 |
+
|
690 |
+
with gr.Column():
|
691 |
+
weather_output = gr.HTML(value=fetch_local_weather())
|
692 |
+
news_output = gr.HTML(value=fetch_local_news())
|
693 |
+
news_output = gr.HTML(value=fetch_local_events())
|
694 |
+
|
695 |
|
696 |
with gr.Column():
|
697 |
image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|