aneesqumar's picture
Update app.py
d27c991 verified
Raw
History Blame Contribute Delete
776 Bytes
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()