ankitchandel09 commited on
Commit
279a327
·
verified ·
1 Parent(s): d087c5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ asr = pipeline("automatic-speech-recognition", model="openai/whisper-small")
5
+ tts = pipeline("text-to-speech", model="espnet/kan-bayashi_ljspeech_vits")
6
+ chatbot = pipeline("text-generation", model="tiiuae/falcon-rw-1b")
7
+
8
+ def voice_bot(audio):
9
+ text = asr(audio)["text"]
10
+ reply = chatbot(text, max_length=50)[0]["generated_text"]
11
+ speech = tts(reply)
12
+ return reply, (speech["sampling_rate"], speech["audio"])
13
+
14
+ gr.Interface(
15
+ fn=voice_bot,
16
+ inputs=gr.Audio(source="microphone", type="filepath"),
17
+ outputs=["text", "audio"],
18
+ title="🎤 AI Voice Assistant"
19
+ ).launch()