File size: 795 Bytes
bcaa3c2
2dc9b79
 
bcaa3c2
2dc9b79
 
 
bcaa3c2
2dc9b79
bcaa3c2
 
 
 
 
 
 
 
 
2dc9b79
bcaa3c2
 
 
2dc9b79
bcaa3c2
2dc9b79
3f8e237
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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()