Spaces:
Runtime error
Runtime error
Yuyang2022
commited on
Commit
•
7cd7a60
1
Parent(s):
1ff5f6d
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
from transformers import pipeline
|
|
|
2 |
import gradio as gr
|
3 |
-
from
|
4 |
|
5 |
pipe = pipeline(model="Yuyang2022/yue") # change to "your-username/the-name-you-picked"
|
6 |
-
|
|
|
7 |
|
8 |
-
|
9 |
-
def translate(audio, language):
|
10 |
text = pipe(audio)["text"]
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
outputs="audio",
|
20 |
-
title="translation-speeh to speech",
|
21 |
-
description="Realtime demo for speech translation.",
|
22 |
-
)
|
23 |
|
24 |
-
|
|
|
1 |
from transformers import pipeline
|
2 |
+
import tempfile
|
3 |
import gradio as gr
|
4 |
+
from neon_tts_plugin_coqui import CoquiTTS
|
5 |
|
6 |
pipe = pipeline(model="Yuyang2022/yue") # change to "your-username/the-name-you-picked"
|
7 |
+
LANGUAGES = list(CoquiTTS.langs.keys())
|
8 |
+
coquiTTS = CoquiTTS()
|
9 |
|
10 |
+
def audio_tts(audio, language: str):
|
|
|
11 |
text = pipe(audio)["text"]
|
12 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
13 |
+
coquiTTS.get_tts(text, fp, speaker = {"language" : language})
|
14 |
+
return fp.name
|
15 |
+
|
16 |
+
inputs = [gr.Audio(source="microphone", type="filepath"),
|
17 |
+
gr.Dropdown(label="Language", LANGUAGES, value="en")]
|
18 |
+
outputs = gr.Audio(label="Output")
|
19 |
|
20 |
+
demo = gr.Interface(fn=audio_tts, inputs=inputs, outputs=outputs,
|
21 |
+
title="translation-speeh to speech",
|
22 |
+
description="Realtime demo for speech translation.",)
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
demo.launch()
|