Pijush2023 commited on
Commit
9a7ba63
·
verified ·
1 Parent(s): 30a1ad8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +754 -49
app.py CHANGED
@@ -63,46 +63,6 @@ def get_current_time_and_date():
63
 
64
  current_time_and_date = get_current_time_and_date()
65
 
66
- # def fetch_local_events():
67
- # api_key = os.environ['SERP_API']
68
- # url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
69
- # response = requests.get(url)
70
- # if response.status_code == 200:
71
- # events_results = response.json().get("events_results", [])
72
- # events_html = """
73
- # <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Events</h2>
74
- # <style>
75
- # .event-item {
76
- # font-family: 'Verdana', sans-serif;
77
- # color: #333;
78
- # margin-bottom: 15px;
79
- # padding: 10px;
80
- # font-weight: bold;
81
- # }
82
- # .event-item a {
83
- # color: #1E90FF;
84
- # text-decoration: none;
85
- # }
86
- # .event-item a:hover {
87
- # text-decoration: underline;
88
- # }
89
- # </style>
90
- # """
91
- # for index, event in enumerate(events_results):
92
- # title = event.get("title", "No title")
93
- # date = event.get("date", "No date")
94
- # location = event.get("address", "No location")
95
- # link = event.get("link", "#")
96
- # events_html += f"""
97
- # <div class="event-item">
98
- # <a href='{link}' target='_blank'>{index + 1}. {title}</a>
99
- # <p>Date: {date}<br>Location: {location}</p>
100
- # </div>
101
- # """
102
- # return events_html
103
- # else:
104
- # return "<p>Failed to fetch local events</p>"
105
-
106
  def fetch_local_events():
107
  api_key = os.environ['SERP_API']
108
  url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
@@ -166,7 +126,6 @@ def fetch_local_events():
166
  else:
167
  return "<p>Failed to fetch local events</p>"
168
 
169
-
170
  def fetch_local_weather():
171
  try:
172
  api_key = os.environ['WEATHER_API']
@@ -327,7 +286,8 @@ def bot(history, choice, tts_choice):
327
  audio_future = executor.submit(generate_audio_parler_tts, response)
328
  elif tts_choice == "MARS5":
329
  audio_future = executor.submit(generate_audio_mars5, response)
330
-
 
331
 
332
  for character in response:
333
  history[-1][1] += character
@@ -660,8 +620,8 @@ def generate_image(prompt):
660
  ).images[0]
661
  return image
662
 
663
- hardcoded_prompt_1 = "Give a high quality photograph of a great looking red 2026 Toyota coupe against a skyline setting in the night, michael mann style in omaha enticing the consumer to buy this product"
664
- hardcoded_prompt_2 = "A vibrant and dynamic football game scene in the style of Peter Paul Rubens, showcasing the intense match between Alabama and Nebraska. The players are depicted with the dramatic, muscular physiques and expressive faces typical of Rubens' style. The Alabama team is wearing their iconic crimson and white uniforms, while the Nebraska team is in their classic red and white attire. The scene is filled with action, with players in mid-motion, tackling, running, and catching the ball. The background features a grand stadium filled with cheering fans, banners, and the natural landscape in the distance. The colors are rich and vibrant, with a strong use of light and shadow to create depth and drama. The overall atmosphere captures the intensity and excitement of the game, infused with the grandeur and dynamism characteristic of Rubens' work."
665
  hardcoded_prompt_3 = "Create a high-energy scene of a DJ performing on a large stage with vibrant lights, colorful lasers, a lively dancing crowd, and various electronic equipment in the background."
666
 
667
  def update_images():
@@ -670,6 +630,18 @@ def update_images():
670
  image_3 = generate_image(hardcoded_prompt_3)
671
  return image_1, image_2, image_3
672
 
 
 
 
 
 
 
 
 
 
 
 
 
673
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
674
  with gr.Row():
675
  with gr.Column():
@@ -681,7 +653,7 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
681
  gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
682
  chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
683
  chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
684
- tts_choice = gr.Radio(label="Select TTS System", choices=["Eleven Labs", "Parler-TTS", "MARS5"], value="Eleven Labs")
685
  bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
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)
@@ -690,10 +662,10 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
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="SAMLOne_real_time")
693
- with gr.Column():
694
- weather_output = gr.HTML(value=fetch_local_weather())
695
- news_output = gr.HTML(value=fetch_local_news())
696
- news_output = gr.HTML(value=fetch_local_events())
697
 
698
  with gr.Column():
699
  image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
@@ -722,6 +694,739 @@ demo.launch(share=True)
722
 
723
 
724
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
725
  ##-------------------------------------------------------------------------Split Code--------------------------------------------------------------------------------------##
726
 
727
 
 
63
 
64
  current_time_and_date = get_current_time_and_date()
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  def fetch_local_events():
67
  api_key = os.environ['SERP_API']
68
  url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
 
126
  else:
127
  return "<p>Failed to fetch local events</p>"
128
 
 
129
  def fetch_local_weather():
130
  try:
131
  api_key = os.environ['WEATHER_API']
 
286
  audio_future = executor.submit(generate_audio_parler_tts, response)
287
  elif tts_choice == "MARS5":
288
  audio_future = executor.submit(generate_audio_mars5, response)
289
+ elif tts_choice == "FishAudio":
290
+ audio_future = executor.submit(generate_audio_fishaudio, response)
291
 
292
  for character in response:
293
  history[-1][1] += character
 
620
  ).images[0]
621
  return image
622
 
623
+ hardcoded_prompt_1="Give a high quality photograph of a great looking red 2026 toyota coupe against a skyline setting in th night, michael mann style in omaha enticing the consumer to buy this product"
624
+ hardcoded_prompt_2="A vibrant and dynamic football game scene in the style of Peter Paul Rubens, showcasing the intense match between Alabama and Nebraska. The players are depicted with the dramatic, muscular physiques and expressive faces typical of Rubens' style. The Alabama team is wearing their iconic crimson and white uniforms, while the Nebraska team is in their classic red and white attire. The scene is filled with action, with players in mid-motion, tackling, running, and catching the ball. The background features a grand stadium filled with cheering fans, banners, and the natural landscape in the distance. The colors are rich and vibrant, with a strong use of light and shadow to create depth and drama. The overall atmosphere captures the intensity and excitement of the game, infused with the grandeur and dynamism characteristic of Rubens' work."
625
  hardcoded_prompt_3 = "Create a high-energy scene of a DJ performing on a large stage with vibrant lights, colorful lasers, a lively dancing crowd, and various electronic equipment in the background."
626
 
627
  def update_images():
 
630
  image_3 = generate_image(hardcoded_prompt_3)
631
  return image_1, image_2, image_3
632
 
633
+ # New TTS function for FishAudio
634
+ def generate_audio_fishaudio(text):
635
+ pipe = pipeline("text-to-speech", model="fishaudio/fish-speech-1.2")
636
+ audio = pipe(text)
637
+
638
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
639
+ audio.save(f.name)
640
+ temp_audio_path = f.name
641
+
642
+ logging.debug(f"Audio saved to {temp_audio_path}")
643
+ return temp_audio_path
644
+
645
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
646
  with gr.Row():
647
  with gr.Column():
 
653
  gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
654
  chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
655
  chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
656
+ tts_choice = gr.Radio(label="Select TTS System", choices=["Eleven Labs", "Parler-TTS", "MARS5", "FishAudio"], value="Eleven Labs")
657
  bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
658
  bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
659
  chatbot.like(print_like_dislike, None, None)
 
662
 
663
  audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
664
  audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
665
+ # with gr.Column():
666
+ # weather_output = gr.HTML(value=fetch_local_weather())
667
+ # news_output = gr.HTML(value=fetch_local_news())
668
+ # news_output = gr.HTML(value=fetch_local_events())
669
 
670
  with gr.Column():
671
  image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
 
694
 
695
 
696
 
697
+
698
+
699
+
700
+
701
+
702
+
703
+
704
+
705
+ #--------------------------------------------------------- Split code-1---------------------------------------------------------------------------------------------------
706
+ # import gradio as gr
707
+ # import requests
708
+ # import os
709
+ # import time
710
+ # import re
711
+ # import logging
712
+ # import tempfile
713
+ # import folium
714
+ # import concurrent.futures
715
+ # import torch
716
+ # from PIL import Image
717
+ # from datetime import datetime
718
+ # from transformers import pipeline, AutoModelForSpeechSeq2Seq, AutoProcessor
719
+ # from googlemaps import Client as GoogleMapsClient
720
+ # from gtts import gTTS
721
+ # from diffusers import StableDiffusionPipeline
722
+ # from langchain_openai import OpenAIEmbeddings, ChatOpenAI
723
+ # from langchain_pinecone import PineconeVectorStore
724
+ # from langchain.prompts import PromptTemplate
725
+ # from langchain.chains import RetrievalQA
726
+ # from langchain.chains.conversation.memory import ConversationBufferWindowMemory
727
+ # from langchain.agents import Tool, initialize_agent
728
+ # from huggingface_hub import login
729
+ # from transformers.models.speecht5.number_normalizer import EnglishNumberNormalizer
730
+ # from parler_tts import ParlerTTSForConditionalGeneration
731
+ # from transformers import AutoTokenizer, AutoFeatureExtractor, set_seed
732
+ # from scipy.io.wavfile import write as write_wav
733
+ # from pydub import AudioSegment
734
+ # from string import punctuation
735
+ # import librosa
736
+ # from pathlib import Path
737
+ # import torchaudio
738
+
739
+ # # Check if the token is already set in the environment variables
740
+ # hf_token = os.getenv("HF_TOKEN")
741
+ # if hf_token is None:
742
+ # print("Please set your Hugging Face token in the environment variables.")
743
+ # else:
744
+ # login(token=hf_token)
745
+
746
+ # logging.basicConfig(level=logging.DEBUG)
747
+
748
+ # embeddings = OpenAIEmbeddings(api_key=os.environ['OPENAI_API_KEY'])
749
+
750
+ # from pinecone import Pinecone
751
+ # pc = Pinecone(api_key=os.environ['PINECONE_API_KEY'])
752
+
753
+ # index_name = "birmingham-dataset"
754
+ # vectorstore = PineconeVectorStore(index_name=index_name, embedding=embeddings)
755
+ # retriever = vectorstore.as_retriever(search_kwargs={'k': 5})
756
+
757
+ # chat_model = ChatOpenAI(api_key=os.environ['OPENAI_API_KEY'], temperature=0, model='gpt-4o')
758
+
759
+ # conversational_memory = ConversationBufferWindowMemory(
760
+ # memory_key='chat_history',
761
+ # k=10,
762
+ # return_messages=True
763
+ # )
764
+
765
+ # def get_current_time_and_date():
766
+ # now = datetime.now()
767
+ # return now.strftime("%Y-%m-%d %H:%M:%S")
768
+
769
+ # current_time_and_date = get_current_time_and_date()
770
+
771
+ # # def fetch_local_events():
772
+ # # api_key = os.environ['SERP_API']
773
+ # # url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
774
+ # # response = requests.get(url)
775
+ # # if response.status_code == 200:
776
+ # # events_results = response.json().get("events_results", [])
777
+ # # events_html = """
778
+ # # <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Events</h2>
779
+ # # <style>
780
+ # # .event-item {
781
+ # # font-family: 'Verdana', sans-serif;
782
+ # # color: #333;
783
+ # # margin-bottom: 15px;
784
+ # # padding: 10px;
785
+ # # font-weight: bold;
786
+ # # }
787
+ # # .event-item a {
788
+ # # color: #1E90FF;
789
+ # # text-decoration: none;
790
+ # # }
791
+ # # .event-item a:hover {
792
+ # # text-decoration: underline;
793
+ # # }
794
+ # # </style>
795
+ # # """
796
+ # # for index, event in enumerate(events_results):
797
+ # # title = event.get("title", "No title")
798
+ # # date = event.get("date", "No date")
799
+ # # location = event.get("address", "No location")
800
+ # # link = event.get("link", "#")
801
+ # # events_html += f"""
802
+ # # <div class="event-item">
803
+ # # <a href='{link}' target='_blank'>{index + 1}. {title}</a>
804
+ # # <p>Date: {date}<br>Location: {location}</p>
805
+ # # </div>
806
+ # # """
807
+ # # return events_html
808
+ # # else:
809
+ # # return "<p>Failed to fetch local events</p>"
810
+
811
+ # def fetch_local_events():
812
+ # api_key = os.environ['SERP_API']
813
+ # url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
814
+ # response = requests.get(url)
815
+ # if response.status_code == 200:
816
+ # events_results = response.json().get("events_results", [])
817
+ # events_html = """
818
+ # <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Events</h2>
819
+ # <style>
820
+ # table {
821
+ # font-family: 'Verdana', sans-serif;
822
+ # color: #333;
823
+ # border-collapse: collapse;
824
+ # width: 100%;
825
+ # }
826
+ # th, td {
827
+ # border: 1px solid #ddd;
828
+ # padding: 8px;
829
+ # }
830
+ # th {
831
+ # background-color: #f2f2f2;
832
+ # color: #333;
833
+ # text-align: left;
834
+ # }
835
+ # tr:hover {
836
+ # background-color: #f5f5f5;
837
+ # }
838
+ # .event-link {
839
+ # color: #1E90FF;
840
+ # text-decoration: none;
841
+ # }
842
+ # .event-link:hover {
843
+ # text-decoration: underline;
844
+ # }
845
+ # </style>
846
+ # <table>
847
+ # <tr>
848
+ # <th>Title</th>
849
+ # <th>Date and Time</th>
850
+ # <th>Location</th>
851
+ # </tr>
852
+ # """
853
+ # for event in events_results:
854
+ # title = event.get("title", "No title")
855
+ # date_info = event.get("date", {})
856
+ # date = f"{date_info.get('start_date', '')} {date_info.get('when', '')}".replace("{", "").replace("}", "")
857
+ # location = event.get("address", "No location")
858
+ # if isinstance(location, list):
859
+ # location = " ".join(location)
860
+ # location = location.replace("[", "").replace("]", "")
861
+ # link = event.get("link", "#")
862
+ # events_html += f"""
863
+ # <tr>
864
+ # <td><a class='event-link' href='{link}' target='_blank'>{title}</a></td>
865
+ # <td>{date}</td>
866
+ # <td>{location}</td>
867
+ # </tr>
868
+ # """
869
+ # events_html += "</table>"
870
+ # return events_html
871
+ # else:
872
+ # return "<p>Failed to fetch local events</p>"
873
+
874
+
875
+ # def fetch_local_weather():
876
+ # try:
877
+ # api_key = os.environ['WEATHER_API']
878
+ # url = f'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/birmingham?unitGroup=metric&include=events%2Calerts%2Chours%2Cdays%2Ccurrent&key={api_key}'
879
+ # response = requests.get(url)
880
+ # response.raise_for_status()
881
+ # jsonData = response.json()
882
+
883
+ # current_conditions = jsonData.get("currentConditions", {})
884
+ # temp_celsius = current_conditions.get("temp", "N/A")
885
+
886
+ # if temp_celsius != "N/A":
887
+ # temp_fahrenheit = int((temp_celsius * 9/5) + 32)
888
+ # else:
889
+ # temp_fahrenheit = "N/A"
890
+
891
+ # condition = current_conditions.get("conditions", "N/A")
892
+ # humidity = current_conditions.get("humidity", "N/A")
893
+
894
+ # weather_html = f"""
895
+ # <div class="weather-theme">
896
+ # <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Weather</h2>
897
+ # <div class="weather-content">
898
+ # <div class="weather-icon">
899
+ # <img src="https://www.weatherbit.io/static/img/icons/{get_weather_icon(condition)}.png" alt="{condition}" style="width: 100px; height: 100px;">
900
+ # </div>
901
+ # <div class="weather-details">
902
+ # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Temperature: {temp_fahrenheit}°F</p>
903
+ # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Condition: {condition}</p>
904
+ # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Humidity: {humidity}%</p>
905
+ # </div>
906
+ # </div>
907
+ # </div>
908
+ # <style>
909
+ # .weather-theme {{
910
+ # animation: backgroundAnimation 10s infinite alternate;
911
+ # border-radius: 10px;
912
+ # padding: 10px;
913
+ # margin-bottom: 15px;
914
+ # background: linear-gradient(45deg, #ffcc33, #ff6666, #ffcc33, #ff6666);
915
+ # background-size: 400% 400%;
916
+ # box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
917
+ # transition: box-shadow 0.3s ease, background-color 0.3s ease;
918
+ # }}
919
+ # .weather-theme:hover {{
920
+ # box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
921
+ # background-position: 100% 100%;
922
+ # }}
923
+ # @keyframes backgroundAnimation {{
924
+ # 0% {{ background-position: 0% 50%; }}
925
+ # 100% {{ background-position: 100% 50%; }}
926
+ # }}
927
+ # .weather-content {{
928
+ # display: flex;
929
+ # align-items: center;
930
+ # }}
931
+ # .weather-icon {{
932
+ # flex: 1;
933
+ # }}
934
+ # .weather-details {{
935
+ # flex: 3;
936
+ # }}
937
+ # </style>
938
+ # """
939
+ # return weather_html
940
+ # except requests.exceptions.RequestException as e:
941
+ # return f"<p>Failed to fetch local weather: {e}</p>"
942
+
943
+ # def get_weather_icon(condition):
944
+ # condition_map = {
945
+ # "Clear": "c01d",
946
+ # "Partly Cloudy": "c02d",
947
+ # "Cloudy": "c03d",
948
+ # "Overcast": "c04d",
949
+ # "Mist": "a01d",
950
+ # "Patchy rain possible": "r01d",
951
+ # "Light rain": "r02d",
952
+ # "Moderate rain": "r03d",
953
+ # "Heavy rain": "r04d",
954
+ # "Snow": "s01d",
955
+ # "Thunderstorm": "t01d",
956
+ # "Fog": "a05d",
957
+ # }
958
+ # return condition_map.get(condition, "c04d")
959
+
960
+ # template1 = """You are an expert concierge who is helpful and a renowned guide for Birmingham,Alabama. Based on weather being a sunny bright day and the today's date is 1st july 2024, use the following pieces of context,
961
+ # memory, and message history, along with your knowledge of perennial events in Birmingham,Alabama, to answer the question at the end. If you don't know the answer, just say "Homie, I need to get more data for this," and don't try to make up an answer.
962
+ # Use fifteen sentences maximum. Keep the answer as detailed as possible. Always include the address, time, date, and
963
+ # event type and description. Always say "It was my pleasure!" at the end of the answer.
964
+ # {context}
965
+ # Question: {question}
966
+ # Helpful Answer:"""
967
+
968
+ # template2 = """You are an expert concierge who is helpful and a renowned guide for Birmingham,Alabama. Based on today's weather being a sunny bright day and today's date is 1st july 2024, take the location or address but don't show the location or address on the output prompts. Use the following pieces of context,
969
+ # memory, and message history, along with your knowledge of perennial events in Birmingham,Alabama, to answer the question at the end. If you don't know the answer, just say "Homie, I need to get more data for this," and don't try to make up an answer.
970
+ # Keep the answer short and sweet and crisp. Always say "It was my pleasure!" at the end of the answer.
971
+ # {context}
972
+ # Question: {question}
973
+ # Helpful Answer:"""
974
+
975
+ # QA_CHAIN_PROMPT_1 = PromptTemplate(input_variables=["context", "question"], template=template1)
976
+ # QA_CHAIN_PROMPT_2 = PromptTemplate(input_variables=["context", "question"], template=template2)
977
+
978
+ # def build_qa_chain(prompt_template):
979
+ # qa_chain = RetrievalQA.from_chain_type(
980
+ # llm=chat_model,
981
+ # chain_type="stuff",
982
+ # retriever=retriever,
983
+ # chain_type_kwargs={"prompt": prompt_template}
984
+ # )
985
+ # tools = [
986
+ # Tool(
987
+ # name='Knowledge Base',
988
+ # func=qa_chain,
989
+ # description='Use this tool when answering general knowledge queries to get more information about the topic'
990
+ # )
991
+ # ]
992
+ # return qa_chain, tools
993
+
994
+ # def initialize_agent_with_prompt(prompt_template):
995
+ # qa_chain, tools = build_qa_chain(prompt_template)
996
+ # agent = initialize_agent(
997
+ # agent='chat-conversational-react-description',
998
+ # tools=tools,
999
+ # llm=chat_model,
1000
+ # verbose=False,
1001
+ # max_iteration=5,
1002
+ # early_stopping_method='generate',
1003
+ # memory=conversational_memory
1004
+ # )
1005
+ # return agent
1006
+
1007
+ # def generate_answer(message, choice):
1008
+ # logging.debug(f"generate_answer called with prompt_choice: {choice}")
1009
+
1010
+ # if choice == "Details":
1011
+ # agent = initialize_agent_with_prompt(QA_CHAIN_PROMPT_1)
1012
+ # elif choice == "Conversational":
1013
+ # agent = initialize_agent_with_prompt(QA_CHAIN_PROMPT_2)
1014
+ # else:
1015
+ # logging.error(f"Invalid prompt_choice: {choice}. Defaulting to 'Conversational'")
1016
+ # agent = initialize_agent_with_prompt(QA_CHAIN_PROMPT_2)
1017
+ # response = agent(message)
1018
+
1019
+ # addresses = extract_addresses(response['output'])
1020
+ # return response['output'], addresses
1021
+
1022
+ # def bot(history, choice, tts_choice):
1023
+ # if not history:
1024
+ # return history
1025
+ # response, addresses = generate_answer(history[-1][0], choice)
1026
+ # history[-1][1] = ""
1027
+
1028
+ # with concurrent.futures.ThreadPoolExecutor() as executor:
1029
+ # if tts_choice == "Eleven Labs":
1030
+ # audio_future = executor.submit(generate_audio_elevenlabs, response)
1031
+ # elif tts_choice == "Parler-TTS":
1032
+ # audio_future = executor.submit(generate_audio_parler_tts, response)
1033
+ # elif tts_choice == "MARS5":
1034
+ # audio_future = executor.submit(generate_audio_mars5, response)
1035
+
1036
+
1037
+ # for character in response:
1038
+ # history[-1][1] += character
1039
+ # time.sleep(0.05)
1040
+ # yield history, None
1041
+
1042
+ # audio_path = audio_future.result()
1043
+ # yield history, audio_path
1044
+
1045
+ # def add_message(history, message):
1046
+ # history.append((message, None))
1047
+ # return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
1048
+
1049
+ # def print_like_dislike(x: gr.LikeData):
1050
+ # print(x.index, x.value, x.liked)
1051
+
1052
+ # def extract_addresses(response):
1053
+ # if not isinstance(response, str):
1054
+ # response = str(response)
1055
+ # address_patterns = [
1056
+ # r'([A-Z].*,\sBirmingham,\sAL\s\d{5})',
1057
+ # r'(\d{4}\s.*,\sBirmingham,\sAL\s\d{5})',
1058
+ # r'([A-Z].*,\sAL\s\d{5})',
1059
+ # r'([A-Z].*,.*\sSt,\sBirmingham,\sAL\s\d{5})',
1060
+ # r'([A-Z].*,.*\sStreets,\sBirmingham,\sAL\s\d{5})',
1061
+ # r'(\d{2}.*\sStreets)',
1062
+ # r'([A-Z].*\s\d{2},\sBirmingham,\sAL\s\d{5})',
1063
+ # r'([a-zA-Z]\s Birmingham)'
1064
+ # ]
1065
+ # addresses = []
1066
+ # for pattern in address_patterns:
1067
+ # addresses.extend(re.findall(pattern, response))
1068
+ # return addresses
1069
+
1070
+ # all_addresses = []
1071
+
1072
+ # def generate_map(location_names):
1073
+ # global all_addresses
1074
+ # all_addresses.extend(location_names)
1075
+
1076
+ # api_key = os.environ['GOOGLEMAPS_API_KEY']
1077
+ # gmaps = GoogleMapsClient(key=api_key)
1078
+
1079
+ # m = folium.Map(location=[33.5175,-86.809444], zoom_start=16)
1080
+
1081
+ # for location_name in all_addresses:
1082
+ # geocode_result = gmaps.geocode(location_name)
1083
+ # if geocode_result:
1084
+ # location = geocode_result[0]['geometry']['location']
1085
+ # folium.Marker(
1086
+ # [location['lat'], 'lng'],
1087
+ # tooltip=f"{geocode_result[0]['formatted_address']}"
1088
+ # ).add_to(m)
1089
+
1090
+ # map_html = m._repr_html_()
1091
+ # return map_html
1092
+
1093
+ # def fetch_local_news():
1094
+ # api_key = os.environ['SERP_API']
1095
+ # url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
1096
+ # response = requests.get(url)
1097
+ # if response.status_code == 200:
1098
+ # results = response.json().get("news_results", [])
1099
+ # news_html = """
1100
+ # <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Birmingham Today</h2>
1101
+ # <style>
1102
+ # .news-item {
1103
+ # font-family: 'Verdana', sans-serif;
1104
+ # color: #333;
1105
+ # background-color: #f0f8ff;
1106
+ # margin-bottom: 15px;
1107
+ # padding: 10px;
1108
+ # border-radius: 5px;
1109
+ # transition: box-shadow 0.3s ease, background-color 0.3s ease;
1110
+ # font-weight: bold;
1111
+ # }
1112
+ # .news-item:hover {
1113
+ # box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
1114
+ # background-color: #e6f7ff;
1115
+ # }
1116
+ # .news-item a {
1117
+ # color: #1E90FF;
1118
+ # text-decoration: none;
1119
+ # font-weight: bold;
1120
+ # }
1121
+ # .news-item a:hover {
1122
+ # text-decoration: underline;
1123
+ # }
1124
+ # .news-preview {
1125
+ # position: absolute;
1126
+ # display: none;
1127
+ # border: 1px solid #ccc;
1128
+ # border-radius: 5px;
1129
+ # box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
1130
+ # background-color: white;
1131
+ # z-index: 1000;
1132
+ # max-width: 300px;
1133
+ # padding: 10px;
1134
+ # font-family: 'Verdana', sans-serif;
1135
+ # color: #333;
1136
+ # }
1137
+ # </style>
1138
+ # <script>
1139
+ # function showPreview(event, previewContent) {
1140
+ # var previewBox = document.getElementById('news-preview');
1141
+ # previewBox.innerHTML = previewContent;
1142
+ # previewBox.style.left = event.pageX + 'px';
1143
+ # previewBox.style.top = event.pageY + 'px';
1144
+ # previewBox.style.display = 'block';
1145
+ # }
1146
+ # function hidePreview() {
1147
+ # var previewBox = document.getElementById('news-preview');
1148
+ # previewBox.style.display = 'none';
1149
+ # }
1150
+ # </script>
1151
+ # <div id="news-preview" class="news-preview"></div>
1152
+ # """
1153
+ # for index, result in enumerate(results[:7]):
1154
+ # title = result.get("title", "No title")
1155
+ # link = result.get("link", "#")
1156
+ # snippet = result.get("snippet", "")
1157
+ # news_html += f"""
1158
+ # <div class="news-item" onmouseover="showPreview(event, '{snippet}')" onmouseout="hidePreview()">
1159
+ # <a href='{link}' target='_blank'>{index + 1}. {title}</a>
1160
+ # <p>{snippet}</p>
1161
+ # </div>
1162
+ # """
1163
+ # return news_html
1164
+ # else:
1165
+ # return "<p>Failed to fetch local news</p>"
1166
+
1167
+ # import numpy as np
1168
+ # import torch
1169
+ # from transformers import pipeline, AutoModelForSpeechSeq2Seq, AutoProcessor
1170
+
1171
+ # model_id = 'openai/whisper-large-v3'
1172
+ # device = "cuda:0" if torch.cuda.is_available() else "cpu"
1173
+ # torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
1174
+ # model = AutoModelForSpeechSeq2Seq.from_pretrained(model_id, torch_dtype=torch_dtype).to(device)
1175
+ # processor = AutoProcessor.from_pretrained(model_id)
1176
+
1177
+ # pipe_asr = pipeline("automatic-speech-recognition", model=model, tokenizer=processor.tokenizer, feature_extractor=processor.feature_extractor, max_new_tokens=128, chunk_length_s=15, batch_size=16, torch_dtype=torch_dtype, device=device, return_timestamps=True)
1178
+
1179
+ # base_audio_drive = "/data/audio"
1180
+
1181
+ # def transcribe_function(stream, new_chunk):
1182
+ # try:
1183
+ # sr, y = new_chunk[0], new_chunk[1]
1184
+ # except TypeError:
1185
+ # print(f"Error chunk structure: {type(new_chunk)}, content: {new_chunk}")
1186
+ # return stream, "", None
1187
+
1188
+ # y = y.astype(np.float32) / np.max(np.abs(y))
1189
+
1190
+ # if stream is not None:
1191
+ # stream = np.concatenate([stream, y])
1192
+ # else:
1193
+ # stream = y
1194
+
1195
+ # result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
1196
+
1197
+ # full_text = result.get("text", "")
1198
+
1199
+ # return stream, full_text, result
1200
+
1201
+ # def update_map_with_response(history):
1202
+ # if not history:
1203
+ # return ""
1204
+ # response = history[-1][1]
1205
+ # addresses = extract_addresses(response)
1206
+ # return generate_map(addresses)
1207
+
1208
+ # def clear_textbox():
1209
+ # return ""
1210
+
1211
+ # def show_map_if_details(history,choice):
1212
+ # if choice in ["Details", "Conversational"]:
1213
+ # return gr.update(visible=True), update_map_with_response(history)
1214
+ # else:
1215
+ # return gr.update(visible=False), ""
1216
+
1217
+ # def generate_audio_elevenlabs(text):
1218
+ # XI_API_KEY = os.environ['ELEVENLABS_API']
1219
+ # VOICE_ID = 'd9MIrwLnvDeH7aZb61E9'
1220
+ # tts_url = f"https://api.elevenlabs.io/v1/text-to-speech/{VOICE_ID}/stream"
1221
+ # headers = {
1222
+ # "Accept": "application/json",
1223
+ # "xi-api-key": XI_API_KEY
1224
+ # }
1225
+ # data = {
1226
+ # "text": str(text),
1227
+ # "model_id": "eleven_multilingual_v2",
1228
+ # "voice_settings": {
1229
+ # "stability": 1.0,
1230
+ # "similarity_boost": 0.0,
1231
+ # "style": 0.60,
1232
+ # "use_speaker_boost": False
1233
+ # }
1234
+ # }
1235
+ # response = requests.post(tts_url, headers=headers, json=data, stream=True)
1236
+ # if response.ok:
1237
+ # with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as f:
1238
+ # for chunk in response.iter_content(chunk_size=1024):
1239
+ # f.write(chunk)
1240
+ # temp_audio_path = f.name
1241
+ # logging.debug(f"Audio saved to {temp_audio_path}")
1242
+ # return temp_audio_path
1243
+ # else:
1244
+ # logging.error(f"Error generating audio: {response.text}")
1245
+ # return None
1246
+
1247
+ # repo_id = "parler-tts/parler-tts-mini-expresso"
1248
+
1249
+ # parler_model = ParlerTTSForConditionalGeneration.from_pretrained(repo_id).to(device)
1250
+ # parler_tokenizer = AutoTokenizer.from_pretrained(repo_id)
1251
+ # parler_feature_extractor = AutoFeatureExtractor.from_pretrained(repo_id)
1252
+
1253
+ # SAMPLE_RATE = parler_feature_extractor.sampling_rate
1254
+ # SEED = 42
1255
+
1256
+ # def preprocess(text):
1257
+ # number_normalizer = EnglishNumberNormalizer()
1258
+ # text = number_normalizer(text).strip()
1259
+ # if text[-1] not in punctuation:
1260
+ # text = f"{text}."
1261
+
1262
+ # abbreviations_pattern = r'\b[A-Z][A-Z\.]+\b'
1263
+
1264
+ # def separate_abb(chunk):
1265
+ # chunk = chunk.replace(".", "")
1266
+ # return " ".join(chunk)
1267
+
1268
+ # abbreviations = re.findall(abbreviations_pattern, text)
1269
+ # for abv in abbreviations:
1270
+ # if abv in text:
1271
+ # text = text.replace(abv, separate_abb(abv))
1272
+ # return text
1273
+
1274
+ # def chunk_text(text, max_length=250):
1275
+ # words = text.split()
1276
+ # chunks = []
1277
+ # current_chunk = []
1278
+ # current_length = 0
1279
+
1280
+ # for word in words:
1281
+ # if current_length + len(word) + 1 <= max_length:
1282
+ # current_chunk.append(word)
1283
+ # current_length += len(word) + 1
1284
+ # else:
1285
+ # chunks.append(' '.join(current_chunk))
1286
+ # current_chunk = [word]
1287
+ # current_length = len(word) + 1
1288
+
1289
+ # if current_chunk:
1290
+ # chunks.append(' '.join(current_chunk))
1291
+
1292
+ # return chunks
1293
+
1294
+ # def generate_audio_parler_tts(text):
1295
+ # description = "Thomas speaks with emphasis and excitement at a moderate pace with high quality."
1296
+ # chunks = chunk_text(preprocess(text))
1297
+ # audio_segments = []
1298
+
1299
+ # for chunk in chunks:
1300
+ # inputs = parler_tokenizer(description, return_tensors="pt").to(device)
1301
+ # prompt = parler_tokenizer(chunk, return_tensors="pt").to(device)
1302
+
1303
+ # set_seed(SEED)
1304
+ # generation = parler_model.generate(input_ids=inputs.input_ids, prompt_input_ids=prompt.input_ids)
1305
+ # audio_arr = generation.cpu().numpy().squeeze()
1306
+
1307
+ # temp_audio_path = os.path.join(tempfile.gettempdir(), f"parler_tts_audio_{len(audio_segments)}.wav")
1308
+ # write_wav(temp_audio_path, SAMPLE_RATE, audio_arr)
1309
+ # audio_segments.append(AudioSegment.from_wav(temp_audio_path))
1310
+
1311
+ # combined_audio = sum(audio_segments)
1312
+ # combined_audio_path = os.path.join(tempfile.gettempdir(), "parler_tts_combined_audio.wav")
1313
+ # combined_audio.export(combined_audio_path, format="wav")
1314
+
1315
+ # logging.debug(f"Audio saved to {combined_audio_path}")
1316
+ # return combined_audio_path
1317
+
1318
+ # # Load the MARS5 model
1319
+ # mars5, config_class = torch.hub.load('Camb-ai/mars5-tts', 'mars5_english', trust_repo=True)
1320
+
1321
+ # def generate_audio_mars5(text):
1322
+ # description = "Thomas speaks with emphasis and excitement at a moderate pace with high quality."
1323
+ # kwargs_dict = {
1324
+ # 'temperature': 0.2,
1325
+ # 'top_k': -1,
1326
+ # 'top_p': 0.2,
1327
+ # 'typical_p': 1.0,
1328
+ # 'freq_penalty': 2.6,
1329
+ # 'presence_penalty': 0.4,
1330
+ # 'rep_penalty_window': 100,
1331
+ # 'max_prompt_phones': 360,
1332
+ # 'deep_clone': True,
1333
+ # 'nar_guidance_w': 3
1334
+ # }
1335
+
1336
+ # chunks = chunk_text(preprocess(text))
1337
+ # audio_segments = []
1338
+
1339
+ # for chunk in chunks:
1340
+ # wav = torch.zeros(1, mars5.sr) # Use a placeholder silent audio for the reference
1341
+ # cfg = config_class(**{k: kwargs_dict[k] for k in kwargs_dict if k in config_class.__dataclass_fields__})
1342
+ # ar_codes, wav_out = mars5.tts(chunk, wav, "", cfg=cfg)
1343
+
1344
+
1345
+ # temp_audio_path = os.path.join(tempfile.gettempdir(), f"mars5_audio_{len(audio_segments)}.wav")
1346
+ # torchaudio.save(temp_audio_path, wav_out.unsqueeze(0), mars5.sr)
1347
+ # audio_segments.append(AudioSegment.from_wav(temp_audio_path))
1348
+
1349
+ # combined_audio = sum(audio_segments)
1350
+ # combined_audio_path = os.path.join(tempfile.gettempdir(), "mars5_combined_audio.wav")
1351
+ # combined_audio.export(combined_audio_path, format="wav")
1352
+
1353
+ # logging.debug(f"Audio saved to {combined_audio_path}")
1354
+ # return combined_audio_path
1355
+
1356
+ # pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2", torch_dtype=torch.float16)
1357
+ # pipe.to(device)
1358
+
1359
+ # def generate_image(prompt):
1360
+ # with torch.cuda.amp.autocast():
1361
+ # image = pipe(
1362
+ # prompt,
1363
+ # num_inference_steps=28,
1364
+ # guidance_scale=3.0,
1365
+ # ).images[0]
1366
+ # return image
1367
+
1368
+ # hardcoded_prompt_1 = "Give a high quality photograph of a great looking red 2026 Toyota coupe against a skyline setting in the night, michael mann style in omaha enticing the consumer to buy this product"
1369
+ # hardcoded_prompt_2 = "A vibrant and dynamic football game scene in the style of Peter Paul Rubens, showcasing the intense match between Alabama and Nebraska. The players are depicted with the dramatic, muscular physiques and expressive faces typical of Rubens' style. The Alabama team is wearing their iconic crimson and white uniforms, while the Nebraska team is in their classic red and white attire. The scene is filled with action, with players in mid-motion, tackling, running, and catching the ball. The background features a grand stadium filled with cheering fans, banners, and the natural landscape in the distance. The colors are rich and vibrant, with a strong use of light and shadow to create depth and drama. The overall atmosphere captures the intensity and excitement of the game, infused with the grandeur and dynamism characteristic of Rubens' work."
1370
+ # hardcoded_prompt_3 = "Create a high-energy scene of a DJ performing on a large stage with vibrant lights, colorful lasers, a lively dancing crowd, and various electronic equipment in the background."
1371
+
1372
+ # def update_images():
1373
+ # image_1 = generate_image(hardcoded_prompt_1)
1374
+ # image_2 = generate_image(hardcoded_prompt_2)
1375
+ # image_3 = generate_image(hardcoded_prompt_3)
1376
+ # return image_1, image_2, image_3
1377
+
1378
+ # with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1379
+ # with gr.Row():
1380
+ # with gr.Column():
1381
+ # state = gr.State()
1382
+
1383
+ # chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
1384
+ # choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
1385
+
1386
+ # gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
1387
+ # chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
1388
+ # chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
1389
+ # tts_choice = gr.Radio(label="Select TTS System", choices=["Eleven Labs", "Parler-TTS", "MARS5"], value="Eleven Labs")
1390
+ # bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
1391
+ # bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
1392
+ # chatbot.like(print_like_dislike, None, None)
1393
+ # clear_button = gr.Button("Clear")
1394
+ # clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
1395
+
1396
+ # audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
1397
+ # audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
1398
+ # with gr.Column():
1399
+ # weather_output = gr.HTML(value=fetch_local_weather())
1400
+ # news_output = gr.HTML(value=fetch_local_news())
1401
+ # news_output = gr.HTML(value=fetch_local_events())
1402
+
1403
+ # with gr.Column():
1404
+ # image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
1405
+ # image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
1406
+ # image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
1407
+
1408
+ # refresh_button = gr.Button("Refresh Images")
1409
+ # refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
1410
+
1411
+ # demo.queue()
1412
+ # demo.launch(share=True)
1413
+
1414
+
1415
+
1416
+
1417
+
1418
+
1419
+
1420
+
1421
+
1422
+
1423
+
1424
+
1425
+
1426
+
1427
+
1428
+
1429
+
1430
  ##-------------------------------------------------------------------------Split Code--------------------------------------------------------------------------------------##
1431
 
1432