Yuyang2022 commited on
Commit
fdfce6c
1 Parent(s): 16a78b0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+ from gtts import gTTS
4
+
5
+ pipe = pipeline(model="Yuyang2022/yue") # change to "your-username/the-name-you-picked"
6
+ language = "en"
7
+
8
+
9
+ def translate(audio, language):
10
+ text = pipe(audio)["text"]
11
+
12
+ myobj = gTTS(text=text,lang=language, slow=False, lang_check=True)
13
+
14
+ return myobj.write_to_fp("wav")
15
+
16
+ iface = gr.Interface(
17
+ fn=translate,
18
+ inputs=[gr.Audio(source="microphone", type="filepath"), gr.Textbox(value = "en")],
19
+ outputs="audio",
20
+ title="translation-speeh to speech",
21
+ description="Realtime demo for speech translation.",
22
+ )
23
+
24
+ iface.launch()