easxtn commited on
Commit
38f5b92
1 Parent(s): 32ec769

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+
5
+ speech_to_text = pipeline("automatic-speech-recognition", model="openai/whisper-large-v3")
6
+ text_generation = pipeline("text-generation", model="NousResearch/Hermes-2-Pro-Llama-3-8B")
7
+ text_to_speech = pipeline("text-to-speech", model="kakao-enterprise/vits-ljs")
8
+
9
+ def alexa(audio):
10
+ text = speech_to_text(audio)["text"]
11
+ generate = text_generation(text, max_length=60)[0]["generated_text"]
12
+ speech = text_to_speech(generate, lang="en", num_of_speakers = 2)["speech"]
13
+ return speech
14
+
15
+ gr.Interface.from_pipeline(
16
+ fn = alexa,
17
+ inputs = [gr.inputs.Audio(source="microphone", type="filepath")],
18
+ outputs = [gr.outputs.Audio()], live=True).launch()