Team Ai
Apppublic

jmlon/DataStructures_and_Algorithms

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
3likes
app.py27 linesDownload Raw Back to root
1import uuid2import gradio as gr3 4from assistant import voice_input, chat_response5 6 7 8if __name__ == "__main__":9 10    with gr.Blocks() as demo:11        session_id = str(uuid.uuid4())  # unique session ID12        state = gr.State(value={'session_id': session_id})13        chatbot = gr.Chatbot(type='messages')14        with gr.Row():15            txt = gr.Textbox(show_label=False, placeholder="Type your message here", container=False)16            voice = gr.Audio(type="filepath", sources=["microphone"], label="Or speak your message")17        18        txt_msg = txt.submit(chat_response, inputs=[txt,chatbot,state], outputs=[txt,chatbot])19 20        voice_msg = voice.stop_recording(21            voice_input, inputs=[voice, chatbot, state], outputs=[txt,chatbot]22        )23 24        demo.launch()25 26 27