Spaces:
Running
Running
Yurii Paniv
commited on
Commit
·
eb8c82c
1
Parent(s):
4fdf251
Upload app
Browse files- README.md +4 -0
- app.py +65 -0
- packages.txt +1 -0
README.md
CHANGED
@@ -26,3 +26,7 @@ tts-server --model_path path/to/model.pth.tar \
|
|
26 |
# How to train:
|
27 |
1. Refer to ["Nervous beginner guide"](https://tts.readthedocs.io/en/latest/tutorial_for_nervous_beginners.html) in Coqui TTS docs.
|
28 |
2. Instead of provided `config.json` use one from this repo.
|
|
|
|
|
|
|
|
|
|
26 |
# How to train:
|
27 |
1. Refer to ["Nervous beginner guide"](https://tts.readthedocs.io/en/latest/tutorial_for_nervous_beginners.html) in Coqui TTS docs.
|
28 |
2. Instead of provided `config.json` use one from this repo.
|
29 |
+
|
30 |
+
|
31 |
+
# Attribution
|
32 |
+
Code for `app.py` taken from https://huggingface.co/spaces/julien-c/coqui
|
app.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tempfile
|
2 |
+
from typing import Optional
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
from TTS.utils.manage import ModelManager
|
8 |
+
from TTS.utils.synthesizer import Synthesizer
|
9 |
+
|
10 |
+
MODEL_NAMES = [
|
11 |
+
"uk/mai/glow-tts"
|
12 |
+
]
|
13 |
+
MODELS = {}
|
14 |
+
|
15 |
+
manager = ModelManager()
|
16 |
+
|
17 |
+
for MODEL_NAME in MODEL_NAMES:
|
18 |
+
print(f"downloading {MODEL_NAME}")
|
19 |
+
model_path, config_path, model_item = manager.download_model(
|
20 |
+
f"tts_models/{MODEL_NAME}")
|
21 |
+
vocoder_name: Optional[str] = model_item["default_vocoder"]
|
22 |
+
vocoder_path = None
|
23 |
+
vocoder_config_path = None
|
24 |
+
if vocoder_name is not None:
|
25 |
+
vocoder_path, vocoder_config_path, _ = manager.download_model(
|
26 |
+
vocoder_name)
|
27 |
+
|
28 |
+
synthesizer = Synthesizer(
|
29 |
+
model_path, config_path, None, vocoder_path, vocoder_config_path,
|
30 |
+
)
|
31 |
+
MODELS[MODEL_NAME] = synthesizer
|
32 |
+
|
33 |
+
|
34 |
+
def tts(text: str, model_name: str):
|
35 |
+
print(text, model_name)
|
36 |
+
synthesizer = MODELS.get(model_name, None)
|
37 |
+
if synthesizer is None:
|
38 |
+
raise NameError("model not found")
|
39 |
+
wavs = synthesizer.tts(text)
|
40 |
+
# output = (synthesizer.output_sample_rate, np.array(wavs))
|
41 |
+
# return output
|
42 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
43 |
+
synthesizer.save_wav(wavs, fp)
|
44 |
+
return fp.name
|
45 |
+
|
46 |
+
|
47 |
+
iface = gr.Interface(
|
48 |
+
fn=tts,
|
49 |
+
inputs=[
|
50 |
+
gr.inputs.Textbox(
|
51 |
+
label="Input",
|
52 |
+
default="Привіт, як твої справи?",
|
53 |
+
),
|
54 |
+
gr.inputs.Radio(
|
55 |
+
label="Pick a TTS Model",
|
56 |
+
choices=MODEL_NAMES,
|
57 |
+
),
|
58 |
+
],
|
59 |
+
outputs=gr.outputs.Audio(label="Output"),
|
60 |
+
title="🐸💬 - Coqui TTS",
|
61 |
+
theme="huggingface",
|
62 |
+
description="🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production",
|
63 |
+
article="more info at https://github.com/coqui-ai/TTS",
|
64 |
+
)
|
65 |
+
iface.launch()
|
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
libsndfile1-dev
|