Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -491,142 +491,7 @@ def generate_audio_elevenlabs(text):
|
|
491 |
return None
|
492 |
|
493 |
# Gradio Blocks interface
|
494 |
-
with gr.Blocks() as demo:
|
495 |
-
gr.HTML('''
|
496 |
-
<style>
|
497 |
-
body {
|
498 |
-
margin: 0;
|
499 |
-
padding: 0;
|
500 |
-
overflow: hidden;
|
501 |
-
height: 100%;
|
502 |
-
width: 100%;
|
503 |
-
background: #141E30; /* fallback for old browsers */
|
504 |
-
background: -webkit-linear-gradient(to right, #243B55, #141E30); /* Chrome 10-25, Safari 5.1-6 */
|
505 |
-
background: linear-gradient(to right, #243B55, #141E30);
|
506 |
-
}
|
507 |
-
|
508 |
-
#background-wrap {
|
509 |
-
position: fixed;
|
510 |
-
z-index: -1;
|
511 |
-
top: 0;
|
512 |
-
left: 0;
|
513 |
-
bottom: 0;
|
514 |
-
right: 0;
|
515 |
-
overflow: hidden;
|
516 |
-
}
|
517 |
-
|
518 |
-
.x1 {
|
519 |
-
-webkit-animation: floatUp 10s infinite;
|
520 |
-
animation: floatUp 10s infinite;
|
521 |
-
-webkit-transform: translate3d(0, 0, 0);
|
522 |
-
transform: translate3d(0, 0, 0);
|
523 |
-
}
|
524 |
-
|
525 |
-
.x2 {
|
526 |
-
-webkit-animation: floatUp 15s infinite;
|
527 |
-
animation: floatUp 15s infinite;
|
528 |
-
-webkit-transform: translate3d(0, 0, 0);
|
529 |
-
transform: translate3d(0, 0, 0);
|
530 |
-
}
|
531 |
-
|
532 |
-
.x3 {
|
533 |
-
-webkit-animation: floatUp 20s infinite;
|
534 |
-
animation: floatUp 20s infinite;
|
535 |
-
-webkit-transform: translate3d(0, 0, 0);
|
536 |
-
transform: translate3d(0, 0, 0);
|
537 |
-
}
|
538 |
-
|
539 |
-
.x4 {
|
540 |
-
-webkit-animation: floatUp 25s infinite;
|
541 |
-
animation: floatUp 25s infinite;
|
542 |
-
-webkit-transform: translate3d(0, 0, 0);
|
543 |
-
transform: translate3d(0, 0, 0);
|
544 |
-
}
|
545 |
-
|
546 |
-
.x5 {
|
547 |
-
-webkit-animation: floatUp 30s infinite;
|
548 |
-
animation: floatUp 30s infinite;
|
549 |
-
-webkit-transform: translate3d(0, 0, 0);
|
550 |
-
transform: translate3d(0, 0, 0);
|
551 |
-
}
|
552 |
-
|
553 |
-
@-webkit-keyframes floatUp {
|
554 |
-
0% {
|
555 |
-
-webkit-transform: translateY(100%);
|
556 |
-
transform: translateY(100%);
|
557 |
-
}
|
558 |
-
|
559 |
-
100% {
|
560 |
-
-webkit-transform: translateY(-100%);
|
561 |
-
transform: translateY(-100%);
|
562 |
-
}
|
563 |
-
}
|
564 |
-
|
565 |
-
@keyframes floatUp {
|
566 |
-
0% {
|
567 |
-
-webkit-transform: translateY(100%);
|
568 |
-
transform: translateY(100%);
|
569 |
-
}
|
570 |
-
|
571 |
-
100% {
|
572 |
-
-webkit-transform: translateY(-100%);
|
573 |
-
transform: translateY(-100%);
|
574 |
-
}
|
575 |
-
}
|
576 |
-
|
577 |
-
.bubble {
|
578 |
-
position: absolute;
|
579 |
-
bottom: -100px;
|
580 |
-
-webkit-border-radius: 50%;
|
581 |
-
border-radius: 50%;
|
582 |
-
background: rgba(255, 255, 255, 0.15);
|
583 |
-
-webkit-box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
|
584 |
-
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
|
585 |
-
}
|
586 |
-
|
587 |
-
.bubble.x1 {
|
588 |
-
left: 10%;
|
589 |
-
width: 40px;
|
590 |
-
height: 40px;
|
591 |
-
background: rgba(255, 255, 255, 0.1);
|
592 |
-
}
|
593 |
-
|
594 |
-
.bubble.x2 {
|
595 |
-
left: 20%;
|
596 |
-
width: 80px;
|
597 |
-
height: 80px;
|
598 |
-
background: rgba(255, 255, 255, 0.2);
|
599 |
-
}
|
600 |
-
|
601 |
-
.bubble.x3 {
|
602 |
-
left: 25%;
|
603 |
-
width: 60px;
|
604 |
-
height: 60px;
|
605 |
-
background: rgba(255, 255, 255, 0.15);
|
606 |
-
}
|
607 |
-
|
608 |
-
.bubble.x4 {
|
609 |
-
left: 40%;
|
610 |
-
width: 50px;
|
611 |
-
height: 50px;
|
612 |
-
background: rgba(255, 255, 255, 0.3);
|
613 |
-
}
|
614 |
-
|
615 |
-
.bubble.x5 {
|
616 |
-
left: 50%;
|
617 |
-
width: 90px;
|
618 |
-
height: 90px;
|
619 |
-
background: rgba(255, 255, 255, 0.1);
|
620 |
-
}
|
621 |
-
</style>
|
622 |
-
<div id="background-wrap">
|
623 |
-
<div class="bubble x1"></div>
|
624 |
-
<div class="bubble x2"></div>
|
625 |
-
<div class="bubble x3"></div>
|
626 |
-
<div class="bubble x4"></div>
|
627 |
-
<div class="bubble x5"></div>
|
628 |
-
</div>
|
629 |
-
''')
|
630 |
with gr.Row():
|
631 |
with gr.Column():
|
632 |
gr.HTML('''
|
@@ -654,11 +519,13 @@ with gr.Blocks() as demo:
|
|
654 |
state = gr.State()
|
655 |
with gr.Row():
|
656 |
with gr.Column():
|
657 |
-
gr.Markdown("Choose the prompt")
|
|
|
658 |
choice = gr.Radio(label="Choose a prompt", choices=["Details", "Conversational"], value="Details")
|
659 |
|
660 |
with gr.Column(): # Larger scale for the right column
|
661 |
-
gr.Markdown("Enter the query / Voice Output")
|
|
|
662 |
chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="Transcription")
|
663 |
chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
|
664 |
bot_msg = chat_msg.then(bot, [chatbot, choice], chatbot, api_name="bot_response")
|
@@ -668,24 +535,67 @@ with gr.Blocks() as demo:
|
|
668 |
clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
669 |
|
670 |
with gr.Column(): # Smaller scale for the left column
|
671 |
-
gr.Markdown("Stream your Voice")
|
|
|
672 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
673 |
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
|
674 |
|
675 |
with gr.Row():
|
676 |
with gr.Column():
|
677 |
-
gr.Markdown("Locate the Events")
|
|
|
678 |
location_output = gr.HTML()
|
679 |
bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
|
680 |
with gr.Column():
|
681 |
-
gr.Markdown("Listen the audio")
|
|
|
682 |
audio_output = gr.Audio()
|
683 |
#bot_msg.then(generate_audio_elevenlabs, chatbot, audio_output)
|
684 |
bot_msg_audio = bot_msg.then(lambda history: generate_audio_elevenlabs(history[-1][1]), chatbot, audio_output)
|
685 |
with gr.Column():
|
|
|
|
|
686 |
news_output = gr.HTML(value=fetch_local_events())
|
687 |
|
688 |
-
setup_ui()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
689 |
|
690 |
demo.queue()
|
691 |
demo.launch(share=True)
|
|
|
491 |
return None
|
492 |
|
493 |
# Gradio Blocks interface
|
494 |
+
with gr.Blocks(theme='rawrsor1/Everforest') as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
with gr.Row():
|
496 |
with gr.Column():
|
497 |
gr.HTML('''
|
|
|
519 |
state = gr.State()
|
520 |
with gr.Row():
|
521 |
with gr.Column():
|
522 |
+
gr.Markdown("<h1>Choose the prompt</h1>", elem_id="prompt-markdown")
|
523 |
+
|
524 |
choice = gr.Radio(label="Choose a prompt", choices=["Details", "Conversational"], value="Details")
|
525 |
|
526 |
with gr.Column(): # Larger scale for the right column
|
527 |
+
gr.Markdown("<h1>Enter the query / Voice Output</h1>", elem_id="query-markdown")
|
528 |
+
|
529 |
chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="Transcription")
|
530 |
chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
|
531 |
bot_msg = chat_msg.then(bot, [chatbot, choice], chatbot, api_name="bot_response")
|
|
|
535 |
clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
536 |
|
537 |
with gr.Column(): # Smaller scale for the left column
|
538 |
+
gr.Markdown("<h1>Stream your Voice</h1>", elem_id="voice-markdown")
|
539 |
+
|
540 |
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
541 |
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
|
542 |
|
543 |
with gr.Row():
|
544 |
with gr.Column():
|
545 |
+
gr.Markdown("<h1>Locate the Events</h1>", elem_id="location-markdown")
|
546 |
+
|
547 |
location_output = gr.HTML()
|
548 |
bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
|
549 |
with gr.Column():
|
550 |
+
gr.Markdown("<h1>Listen the audio</h1>", elem_id="audio-markdown")
|
551 |
+
|
552 |
audio_output = gr.Audio()
|
553 |
#bot_msg.then(generate_audio_elevenlabs, chatbot, audio_output)
|
554 |
bot_msg_audio = bot_msg.then(lambda history: generate_audio_elevenlabs(history[-1][1]), chatbot, audio_output)
|
555 |
with gr.Column():
|
556 |
+
gr.Markdown("<h1>Local Events</h1>", elem_id="events-markdown")
|
557 |
+
|
558 |
news_output = gr.HTML(value=fetch_local_events())
|
559 |
|
560 |
+
setup_ui()
|
561 |
+
|
562 |
+
|
563 |
+
# def setup_ui():
|
564 |
+
# state = gr.State()
|
565 |
+
# with gr.Row():
|
566 |
+
# with gr.Column():
|
567 |
+
# gr.Markdown("Choose the prompt")
|
568 |
+
# choice = gr.Radio(label="Choose a prompt", choices=["Details", "Conversational"], value="Details")
|
569 |
+
|
570 |
+
# with gr.Column(): # Larger scale for the right column
|
571 |
+
# gr.Markdown("Enter the query / Voice Output")
|
572 |
+
# chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="Transcription")
|
573 |
+
# chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
|
574 |
+
# bot_msg = chat_msg.then(bot, [chatbot, choice], chatbot, api_name="bot_response")
|
575 |
+
# bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False), None, [chat_input])
|
576 |
+
# chatbot.like(print_like_dislike, None, None)
|
577 |
+
# clear_button = gr.Button("Clear")
|
578 |
+
# clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
579 |
+
|
580 |
+
# with gr.Column(): # Smaller scale for the left column
|
581 |
+
# gr.Markdown("Stream your Voice")
|
582 |
+
# audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
583 |
+
# audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
|
584 |
+
|
585 |
+
# with gr.Row():
|
586 |
+
# with gr.Column():
|
587 |
+
# gr.Markdown("Locate the Events")
|
588 |
+
# location_output = gr.HTML()
|
589 |
+
# bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
|
590 |
+
# with gr.Column():
|
591 |
+
# gr.Markdown("Listen the audio")
|
592 |
+
# audio_output = gr.Audio()
|
593 |
+
# #bot_msg.then(generate_audio_elevenlabs, chatbot, audio_output)
|
594 |
+
# bot_msg_audio = bot_msg.then(lambda history: generate_audio_elevenlabs(history[-1][1]), chatbot, audio_output)
|
595 |
+
# with gr.Column():
|
596 |
+
# news_output = gr.HTML(value=fetch_local_events())
|
597 |
+
|
598 |
+
# setup_ui()
|
599 |
|
600 |
demo.queue()
|
601 |
demo.launch(share=True)
|