Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -520,77 +520,121 @@ def generate_image(prompt):
|
|
| 520 |
# Hardcoded prompt for image generation
|
| 521 |
hardcoded_prompt = "A cat holding a sign that says hello world"
|
| 522 |
|
| 523 |
-
# Gradio Blocks interface
|
| 524 |
-
with gr.Blocks(theme='rawrsor1/Everforest') as demo:
|
| 525 |
-
|
| 526 |
-
|
| 527 |
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
|
| 532 |
-
|
| 533 |
-
|
| 534 |
|
| 535 |
-
|
| 536 |
-
|
| 537 |
|
| 538 |
-
|
| 539 |
-
|
| 540 |
|
| 541 |
-
|
| 542 |
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
|
| 549 |
|
| 550 |
-
|
| 551 |
-
|
| 552 |
|
| 553 |
-
|
| 554 |
|
| 555 |
-
|
| 556 |
-
|
| 557 |
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
|
| 566 |
-
|
| 567 |
-
|
| 568 |
|
| 569 |
-
|
| 570 |
-
|
| 571 |
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
|
| 586 |
-
|
| 587 |
|
| 588 |
-
|
| 589 |
-
|
| 590 |
|
| 591 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 592 |
|
| 593 |
-
|
|
|
|
|
|
|
| 594 |
|
| 595 |
demo.queue()
|
| 596 |
-
demo.launch(share=True)
|
|
|
|
| 520 |
# Hardcoded prompt for image generation
|
| 521 |
hardcoded_prompt = "A cat holding a sign that says hello world"
|
| 522 |
|
| 523 |
+
# # Gradio Blocks interface
|
| 524 |
+
# with gr.Blocks(theme='rawrsor1/Everforest') as demo:
|
| 525 |
+
# with gr.Row():
|
| 526 |
+
# chatbot = gr.Chatbot([], elem_id="chatbot", bubble_full_width=False)
|
| 527 |
|
| 528 |
+
# with gr.Column(scale=5):
|
| 529 |
+
# gr.Markdown("<h1>Generated Image</h1>", elem_id="image-markdown")
|
| 530 |
+
# image_output = gr.Image(value=generate_image(hardcoded_prompt))
|
| 531 |
|
| 532 |
+
# with gr.Column(scale=8):
|
| 533 |
+
# weather_output = gr.HTML(value=fetch_local_weather())
|
| 534 |
|
| 535 |
+
# with gr.Column(scale=5):
|
| 536 |
+
# news_output = gr.HTML(value=fetch_local_news())
|
| 537 |
|
| 538 |
+
# with gr.Column():
|
| 539 |
+
# gr.Markdown("<h1>Local Events</h1>", elem_id="events-markdown")
|
| 540 |
|
| 541 |
+
# news_output = gr.HTML(value=fetch_local_events())
|
| 542 |
|
| 543 |
+
# def setup_ui():
|
| 544 |
+
# state = gr.State()
|
| 545 |
+
# with gr.Row():
|
| 546 |
+
# with gr.Column():
|
| 547 |
+
# chatbot = gr.Chatbot([], elem_id="chatbot", bubble_full_width=False)
|
| 548 |
|
| 549 |
|
| 550 |
+
# with gr.Column():
|
| 551 |
+
# gr.Markdown("<h1>Choose the prompt</h1>", elem_id="prompt-markdown")
|
| 552 |
|
| 553 |
+
# choice = gr.Radio(label="Choose a prompt", choices=["Details", "Conversational"], value="Details")
|
| 554 |
|
| 555 |
+
# with gr.Column(): # Larger scale for the right column
|
| 556 |
+
# gr.Markdown("<h1>Enter the query / Voice Output</h1>", elem_id="query-markdown")
|
| 557 |
|
| 558 |
+
# chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="Transcription")
|
| 559 |
+
# chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
|
| 560 |
+
# bot_msg = chat_msg.then(bot, [chatbot, choice], chatbot, api_name="bot_response")
|
| 561 |
+
# bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False), None, [chat_input])
|
| 562 |
+
# chatbot.like(print_like_dislike, None, None)
|
| 563 |
+
# clear_button = gr.Button("Clear")
|
| 564 |
+
# clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
| 565 |
|
| 566 |
+
# with gr.Column(): # Smaller scale for the left column
|
| 567 |
+
# gr.Markdown("<h1>Stream your Voice</h1>", elem_id="voice-markdown")
|
| 568 |
|
| 569 |
+
# audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
| 570 |
+
# audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
|
| 571 |
|
| 572 |
+
# with gr.Row():
|
| 573 |
+
# with gr.Column():
|
| 574 |
+
# gr.Markdown("<h1>Locate the Events</h1>", elem_id="location-markdown")
|
| 575 |
|
| 576 |
+
# location_output = gr.HTML()
|
| 577 |
+
# bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
|
| 578 |
+
# with gr.Column():
|
| 579 |
+
# gr.Markdown("<h1>Listen the audio</h1>", elem_id="audio-markdown")
|
| 580 |
|
| 581 |
+
# audio_output = gr.Audio()
|
| 582 |
+
# bot_msg_audio = bot_msg.then(lambda history: generate_audio_elevenlabs(history[-1][1]), chatbot, audio_output)
|
| 583 |
+
# with gr.Column():
|
| 584 |
+
# gr.Markdown("<h1>Local Events</h1>", elem_id="events-markdown")
|
| 585 |
|
| 586 |
+
# news_output = gr.HTML(value=fetch_local_events())
|
| 587 |
|
| 588 |
+
# with gr.Column():
|
| 589 |
+
# gr.Markdown("<h1>Generated Image</h1>", elem_id="image-markdown")
|
| 590 |
|
| 591 |
+
# image_output = gr.Image(value=generate_image(hardcoded_prompt))
|
| 592 |
+
|
| 593 |
+
# setup_ui()
|
| 594 |
+
|
| 595 |
+
# demo.queue()
|
| 596 |
+
# demo.launch(share=True)
|
| 597 |
+
import gradio as gr
|
| 598 |
+
|
| 599 |
+
with gr.Blocks(theme='rawrsor1/Everforest') as demo:
|
| 600 |
+
with gr.Row():
|
| 601 |
+
with gr.Column(scale=2):
|
| 602 |
+
chatbot = gr.Chatbot([], elem_id="chatbot", bubble_full_width=False)
|
| 603 |
+
gr.Markdown("<h1>Voice Chat</h1>", elem_id="voice-markdown")
|
| 604 |
+
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
| 605 |
+
state = gr.State()
|
| 606 |
+
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chatbot], api_name="SAMLOne_real_time")
|
| 607 |
+
chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="Transcription")
|
| 608 |
+
chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
|
| 609 |
+
bot_msg = chat_msg.then(bot, [chatbot, choice], chatbot, api_name="bot_response")
|
| 610 |
+
bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False), None, [chat_input])
|
| 611 |
+
chatbot.like(print_like_dislike, None, None)
|
| 612 |
+
clear_button = gr.Button("Clear")
|
| 613 |
+
clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
| 614 |
+
|
| 615 |
+
with gr.Column(scale=1):
|
| 616 |
+
gr.Markdown("<h1>Choose the prompt</h1>", elem_id="prompt-markdown")
|
| 617 |
+
choice = gr.Radio(label="Choose a prompt", choices=["Details", "Conversational"], value="Details")
|
| 618 |
+
|
| 619 |
+
with gr.Row():
|
| 620 |
+
with gr.Column(scale=2):
|
| 621 |
+
gr.Markdown("<h1>Locate the Events</h1>", elem_id="location-markdown")
|
| 622 |
+
location_output = gr.HTML()
|
| 623 |
+
bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
|
| 624 |
+
|
| 625 |
+
with gr.Column(scale=1):
|
| 626 |
+
gr.Markdown("<h1>Generated Audio</h1>", elem_id="audio-markdown")
|
| 627 |
+
audio_output = gr.Audio()
|
| 628 |
+
bot_msg_audio = bot_msg.then(lambda history: generate_audio_elevenlabs(history[-1][1]), chatbot, audio_output)
|
| 629 |
+
|
| 630 |
+
with gr.Row():
|
| 631 |
+
with gr.Column(scale=1):
|
| 632 |
+
gr.Markdown("<h1>Generated Image</h1>", elem_id="image-markdown")
|
| 633 |
+
image_output = gr.Image(value=generate_image(hardcoded_prompt))
|
| 634 |
|
| 635 |
+
with gr.Column(scale=2):
|
| 636 |
+
gr.Markdown("<h1>Local Events</h1>", elem_id="events-markdown")
|
| 637 |
+
news_output = gr.HTML(value=fetch_local_events())
|
| 638 |
|
| 639 |
demo.queue()
|
| 640 |
+
demo.launch(share=True)
|