Spaces:
Build error
Build error
Commit
·
572f08d
0
Parent(s):
Duplicate from eugenesiow/mandarin-tts
Browse filesCo-authored-by: Eugene Siow <[email protected]>
- .gitattributes +27 -0
- .gitignore +3 -0
- README.md +38 -0
- app.py +49 -0
- gradio_queue.db +0 -0
- packages.txt +1 -0
- requirements.txt +0 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
venv/
|
2 |
+
.idea/
|
3 |
+
*.db
|
README.md
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
9 |
+
duplicated_from: eugenesiow/mandarin-tts
|
10 |
+
---
|
11 |
+
|
12 |
+
# Configuration
|
13 |
+
|
14 |
+
`title`: _string_
|
15 |
+
Display title for the Space
|
16 |
+
|
17 |
+
`emoji`: _string_
|
18 |
+
Space emoji (emoji-only character allowed)
|
19 |
+
|
20 |
+
`colorFrom`: _string_
|
21 |
+
Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
|
22 |
+
|
23 |
+
`colorTo`: _string_
|
24 |
+
Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
|
25 |
+
|
26 |
+
`sdk`: _string_
|
27 |
+
Can be either `gradio` or `streamlit`
|
28 |
+
|
29 |
+
`sdk_version` : _string_
|
30 |
+
Only applicable for `streamlit` SDK.
|
31 |
+
See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
|
32 |
+
|
33 |
+
`app_file`: _string_
|
34 |
+
Path to your main application file (which contains either `gradio` or `streamlit` Python code).
|
35 |
+
Path is relative to the root of the repository.
|
36 |
+
|
37 |
+
`pinned`: _boolean_
|
38 |
+
Whether the Space stays on top of your list.
|
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tempfile
|
2 |
+
import gradio as gr
|
3 |
+
# import numpy as np
|
4 |
+
from TTS.utils.manage import ModelManager
|
5 |
+
from TTS.utils.synthesizer import Synthesizer
|
6 |
+
|
7 |
+
|
8 |
+
title = "Mandarin Text-to-Speech (TTS)"
|
9 |
+
description = "Generate mandarin speech from text using a Tachotron2 model with Coqui TTS 🐸, " \
|
10 |
+
"a deep learning toolkit for Text-to-Speech."
|
11 |
+
article = "<p style='text-align: center'><a href='https://news.machinelearning.sg/posts/mandarin_text_to_speech_with_coqui_tts/' target='blank' class='footer'>Blog</a> | <a href='https://github.com/eugenesiow/practical-ml' target='_blank' class='footer'>Github Repo</a></p>"
|
12 |
+
examples = [
|
13 |
+
["语音合成是通过机械的、电子的方法产生人造语音的技术。"],
|
14 |
+
["李显龙总理表示,我国要达到像意大利的开放程度,几乎回到冠病疫情前的生活,还需要一段时间。"]
|
15 |
+
]
|
16 |
+
|
17 |
+
|
18 |
+
manager = ModelManager()
|
19 |
+
model_path, config_path, model_item = manager.download_model("tts_models/zh-CN/baker/tacotron2-DDC-GST")
|
20 |
+
synthesizer = Synthesizer(
|
21 |
+
model_path, config_path, None, None, None,
|
22 |
+
)
|
23 |
+
|
24 |
+
|
25 |
+
def inference(text: str):
|
26 |
+
wavs = synthesizer.tts(text)
|
27 |
+
# output = (synthesizer.output_sample_rate, np.array(wavs).astype(np.float32))
|
28 |
+
# return output
|
29 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
30 |
+
synthesizer.save_wav(wavs, fp)
|
31 |
+
return fp.name
|
32 |
+
|
33 |
+
|
34 |
+
gr.Interface(
|
35 |
+
fn=inference,
|
36 |
+
inputs=[
|
37 |
+
gr.inputs.Textbox(
|
38 |
+
label="Input",
|
39 |
+
default="你好吗?我很好。",
|
40 |
+
),
|
41 |
+
],
|
42 |
+
outputs=gr.outputs.Audio(label="Output"),
|
43 |
+
title=title,
|
44 |
+
description=description,
|
45 |
+
article=article,
|
46 |
+
examples=examples,
|
47 |
+
enable_queue=True,
|
48 |
+
allow_flagging=False,
|
49 |
+
).launch(debug=False)
|
gradio_queue.db
ADDED
Binary file (160 kB). View file
|
|
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
libsndfile1-dev
|
requirements.txt
ADDED
Binary file (22 Bytes). View file
|
|