Jorge Londoño
Updated
3f8e237
raw
history blame contribute delete
795 Bytes
import uuid
import gradio as gr
from assistant import voice_input, chat_response
if __name__ == "__main__":
with gr.Blocks() as demo:
session_id = str(uuid.uuid4()) # unique session ID
state = gr.State(value={'session_id': session_id})
chatbot = gr.Chatbot(type='messages')
with gr.Row():
txt = gr.Textbox(show_label=False, placeholder="Type your message here", container=False)
voice = gr.Audio(type="filepath", sources=["microphone"], label="Or speak your message")
txt_msg = txt.submit(chat_response, inputs=[txt,chatbot,state], outputs=[txt,chatbot])
voice_msg = voice.stop_recording(
voice_input, inputs=[voice, chatbot, state], outputs=[txt,chatbot]
)
demo.launch()