Spaces:
Runtime error
Runtime error
Eugene Siow
commited on
Commit
•
b2bd144
1
Parent(s):
960daf7
Initial commit.
Browse files- .gitignore +2 -0
- README.md +4 -4
- app.py +46 -0
- requirements.txt +0 -0
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
venv/
|
2 |
+
.idea/
|
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
-
title: Mandarin
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
app_file: app.py
|
8 |
pinned: false
|
|
|
1 |
---
|
2 |
+
title: Mandarin Text-to-Speech
|
3 |
+
emoji: 🦜
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: green
|
6 |
sdk: gradio
|
7 |
app_file: app.py
|
8 |
pinned: false
|
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
from TTS.utils.manage import ModelManager
|
4 |
+
from TTS.utils.synthesizer import Synthesizer
|
5 |
+
|
6 |
+
|
7 |
+
title = "Mandarin Text-to-Speech (TTS)"
|
8 |
+
description = "Generate mandarin speech from text using a Tachotron2 model with Coqui TTS 🐸, " \
|
9 |
+
"a deep learning toolkit for Text-to-Speech."
|
10 |
+
article = "<p style='text-align: center'><a href='https://github.com/eugenesiow/practical-ml'>Github</a></p>"
|
11 |
+
examples = [
|
12 |
+
["语音合成是通过机械的、电子的方法产生人造语音的技术。"],
|
13 |
+
["李显龙总理表示,我国要达到像意大利的开放程度,几乎回到冠病疫情前的生活,还需要一段时间。"]
|
14 |
+
]
|
15 |
+
|
16 |
+
|
17 |
+
manager = ModelManager()
|
18 |
+
model_path, config_path, model_item = manager.download_model("tts_models/zh-CN/baker/tacotron2-DDC-GST")
|
19 |
+
synthesizer = Synthesizer(
|
20 |
+
model_path, config_path, None, None, None,
|
21 |
+
)
|
22 |
+
|
23 |
+
|
24 |
+
def inference(text: str):
|
25 |
+
print(text)
|
26 |
+
wavs = synthesizer.tts(text)
|
27 |
+
output = (synthesizer.output_sample_rate, np.array(wavs))
|
28 |
+
return output
|
29 |
+
|
30 |
+
|
31 |
+
gr.Interface(
|
32 |
+
fn=inference,
|
33 |
+
inputs=[
|
34 |
+
gr.inputs.Textbox(
|
35 |
+
label="Input",
|
36 |
+
default="你好吗?我很好。",
|
37 |
+
),
|
38 |
+
],
|
39 |
+
outputs=gr.outputs.Audio(label="Output"),
|
40 |
+
title=title,
|
41 |
+
description=description,
|
42 |
+
article=article,
|
43 |
+
examples=examples,
|
44 |
+
enable_queue=True,
|
45 |
+
allow_flagging=False,
|
46 |
+
).launch(debug=False)
|
requirements.txt
ADDED
Binary file (22 Bytes). View file
|
|