import gradio as gr from stt import speech_to_text from llm import ask_llm from tts import text_to_speech def voice_to_voice(audio): if audio is None: return "Please record audio first", "", None user_text = speech_to_text(audio) if user_text.strip() == "": return "Could not recognize speech", "", None ai_text = ask_llm(user_text) ai_audio = text_to_speech(ai_text) return user_text, ai_text, ai_audio demo = gr.Interface( fn=voice_to_voice, inputs=gr.Audio(type="filepath", label="๐ŸŽค Speak"), outputs=[ gr.Textbox(label="๐Ÿงพ You said"), gr.Textbox(label="๐Ÿค– AI replied"), gr.Audio(label="๐Ÿ”Š AI Voice"), ], title="๐ŸŽค Voice-to-Voice AI (Free & Open Source)", ) demo.launch()