Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| asr = pipeline("automatic-speech-recognition", model="openai/whisper-small") | |
| tts = pipeline("text-to-speech", model="espnet/kan-bayashi_ljspeech_vits") | |
| chatbot = pipeline("text-generation", model="tiiuae/falcon-rw-1b") | |
| def voice_bot(audio): | |
| text = asr(audio)["text"] | |
| reply = chatbot(text, max_length=50)[0]["generated_text"] | |
| speech = tts(reply) | |
| return reply, (speech["sampling_rate"], speech["audio"]) | |
| gr.Interface( | |
| fn=voice_bot, | |
| inputs=gr.Audio(source="microphone", type="filepath"), | |
| outputs=["text", "audio"], | |
| title="π€ AI Voice Assistant" | |
| ).launch() | |