Pijush2023 commited on
Commit
df40f1d
·
verified ·
1 Parent(s): 131c43b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -1086,7 +1086,7 @@ def fetch_local_news():
1086
  api_key = os.environ['SERP_API']
1087
  url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
1088
  response = requests.get(url)
1089
- if response.status_code == 200:
1090
  results = response.json().get("news_results", [])
1091
  news_html = """
1092
  <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Birmingham Today</h2>
@@ -1398,16 +1398,16 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1398
  chatbot.like(print_like_dislike, None, None)
1399
  clear_button = gr.Button("Clear")
1400
  clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
1401
-
1402
- audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
1403
- audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="voice_query_to_text")
1404
-
1405
- # New integration
1406
- transcribe_button = gr.Button("Transcribe")
1407
- transcribe_output = gr.Textbox(show_label=False)
1408
- transcribe_button.click(fn=transcribe, inputs=[audio_input], outputs=[transcribe_output])
1409
- transcribe_output.submit(add_message, [chatbot, transcribe_output], [chatbot, chat_input], api_name="transcribe_and_ask")
1410
 
 
 
 
 
 
 
 
 
 
1411
  with gr.Column():
1412
  image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
1413
  image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
@@ -1420,5 +1420,3 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1420
 
1421
  demo.queue()
1422
  demo.launch(share=True)
1423
-
1424
-
 
1086
  api_key = os.environ['SERP_API']
1087
  url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
1088
  response = requests.get(url)
1089
+ if response.status_code == 200):
1090
  results = response.json().get("news_results", [])
1091
  news_html = """
1092
  <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Birmingham Today</h2>
 
1398
  chatbot.like(print_like_dislike, None, None)
1399
  clear_button = gr.Button("Clear")
1400
  clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
 
 
 
 
 
 
 
 
 
1401
 
1402
+ # Recorder section
1403
+ with gr.Group():
1404
+ gr.Markdown("<h2>Audio Recorder</h2>")
1405
+ audio_input = gr.Audio(sources=["microphone"], type='numpy')
1406
+ transcribe_button = gr.Button("Transcribe")
1407
+ transcribe_output = gr.Textbox(show_label=False, placeholder="Transcribed text will appear here...")
1408
+ transcribe_button.click(fn=transcribe, inputs=[audio_input], outputs=[transcribe_output])
1409
+ transcribe_output.submit(add_message, [chatbot, transcribe_output], [chatbot, chat_input])
1410
+
1411
  with gr.Column():
1412
  image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
1413
  image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
 
1420
 
1421
  demo.queue()
1422
  demo.launch(share=True)