voice_assistant / app.py
ankitchandel09's picture
Update app.py
279a327 verified
raw
history blame contribute delete
644 Bytes
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()