Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -317,7 +317,7 @@ def fetch_local_news():
|
|
317 |
api_key = os.environ['SERP_API']
|
318 |
url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
|
319 |
response = requests.get(url)
|
320 |
-
if response.status_code == 200:
|
321 |
results = response.json().get("news_results", [])
|
322 |
news_html = """
|
323 |
<h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Birmingham Today</h2>
|
@@ -504,9 +504,8 @@ def generate_audio_parler_tts(text):
|
|
504 |
audio_arr = generation.cpu().numpy().squeeze()
|
505 |
|
506 |
temp_audio_path = os.path.join(tempfile.gettempdir(), "parler_tts_audio.wav")
|
507 |
-
|
508 |
-
|
509 |
-
f.write(audio_arr.tobytes())
|
510 |
|
511 |
logging.debug(f"Audio saved to {temp_audio_path}")
|
512 |
return temp_audio_path
|
@@ -554,14 +553,14 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
554 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
555 |
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
|
556 |
|
557 |
-
gr.Markdown("<h1 style='color: red;'>Map</h1>", elem_id="location-markdown")
|
558 |
-
location_output = gr.HTML()
|
559 |
-
bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
|
560 |
|
561 |
-
with gr.Column():
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
|
566 |
with gr.Column():
|
567 |
image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
@@ -573,4 +572,3 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
573 |
|
574 |
demo.queue()
|
575 |
demo.launch(share=True)
|
576 |
-
|
|
|
317 |
api_key = os.environ['SERP_API']
|
318 |
url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
|
319 |
response = requests.get(url)
|
320 |
+
if response.status_code == 200):
|
321 |
results = response.json().get("news_results", [])
|
322 |
news_html = """
|
323 |
<h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Birmingham Today</h2>
|
|
|
504 |
audio_arr = generation.cpu().numpy().squeeze()
|
505 |
|
506 |
temp_audio_path = os.path.join(tempfile.gettempdir(), "parler_tts_audio.wav")
|
507 |
+
from scipy.io.wavfile import write as write_wav
|
508 |
+
write_wav(temp_audio_path, SAMPLE_RATE, audio_arr)
|
|
|
509 |
|
510 |
logging.debug(f"Audio saved to {temp_audio_path}")
|
511 |
return temp_audio_path
|
|
|
553 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
554 |
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
|
555 |
|
556 |
+
# gr.Markdown("<h1 style='color: red;'>Map</h1>", elem_id="location-markdown")
|
557 |
+
# location_output = gr.HTML()
|
558 |
+
# bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
|
559 |
|
560 |
+
# with gr.Column():
|
561 |
+
# weather_output = gr.HTML(value=fetch_local_weather())
|
562 |
+
# news_output = gr.HTML(value=fetch_local_news())
|
563 |
+
# events_output = gr.HTML(value=fetch_local_events())
|
564 |
|
565 |
with gr.Column():
|
566 |
image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
|
|
572 |
|
573 |
demo.queue()
|
574 |
demo.launch(share=True)
|
|