Eren Gölge commited on
Commit
3ee94dd
1 Parent(s): f78679d

First commit

Browse files
Files changed (4) hide show
  1. README.md +3 -3
  2. app.py +105 -0
  3. packages.txt +1 -0
  4. requirments.txt +1 -0
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
- title: CoquiTTS
3
- emoji: 💩
4
  colorFrom: green
5
  colorTo: red
6
  sdk: gradio
@@ -26,7 +26,7 @@ Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gr
26
  Can be either `gradio`, `streamlit`, or `static`
27
 
28
  `sdk_version` : _string_
29
- Only applicable for `streamlit` SDK.
30
  See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
31
 
32
  `app_file`: _string_
 
1
  ---
2
+ title: CoquiTTS (Official)
3
+ emoji: 🐸
4
  colorFrom: green
5
  colorTo: red
6
  sdk: gradio
 
26
  Can be either `gradio`, `streamlit`, or `static`
27
 
28
  `sdk_version` : _string_
29
+ Only applicable for `streamlit` SDK.
30
  See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
31
 
32
  `app_file`: _string_
app.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tempfile
2
+ from typing import Optional
3
+ from TTS.config import load_config
4
+ import gradio as gr
5
+ import numpy as np
6
+ from TTS.utils.manage import ModelManager
7
+ from TTS.utils.synthesizer import Synthesizer
8
+
9
+
10
+ MODELS = {}
11
+ SPEAKERS = {}
12
+
13
+
14
+ manager = ModelManager()
15
+ MODEL_NAMES = manager.list_tts_models()
16
+
17
+ # reorder models
18
+ ddc = MODEL_NAMES[1]
19
+ MODEL_NAMES[1] = MODEL_NAMES[0]
20
+ MODEL_NAMES[0] = ddc
21
+
22
+
23
+ # filter out multi-speaker models
24
+ filters = ["vctk", "your_tts"]
25
+ MODEL_NAMES = [model_name for model_name in MODEL_NAMES if not any(f in model_name for f in filters)]
26
+ print(MODEL_NAMES)
27
+
28
+
29
+ def tts(text: str, model_name: str, speaker_idx: str=None):
30
+ print(text, model_name)
31
+ # download model
32
+ model_path, config_path, model_item = manager.download_model(f"tts_models/{model_name}")
33
+ vocoder_name: Optional[str] = model_item["default_vocoder"]
34
+ # download vocoder
35
+ vocoder_path = None
36
+ vocoder_config_path = None
37
+ if vocoder_name is not None:
38
+ vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name)
39
+ # init synthesizer
40
+ synthesizer = Synthesizer(
41
+ model_path, config_path, None, None, vocoder_path, vocoder_config_path,
42
+ )
43
+ # synthesize
44
+ if synthesizer is None:
45
+ raise NameError("model not found")
46
+ wavs = synthesizer.tts(text, speaker_idx)
47
+ # return output
48
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
49
+ synthesizer.save_wav(wavs, fp)
50
+ return fp.name
51
+
52
+
53
+
54
+ article= """
55
+ ### Visit us on <a href=https://coqui.ai>Coqui.ai</a> and drop a 🌟 to <a href=https://github.com/coqui-ai/TTS>CoquiTTS</a>.
56
+
57
+ ### You can run CoquiTTS on your machine. Check out our <a href="https://tts.readthedocs.io/en/latest/inference.html">documentation</a>.
58
+
59
+
60
+ ```bash
61
+ $ pip install TTS
62
+ ...
63
+ $ tts --list_models
64
+ ...
65
+ $ tts --text "Text for TTS" --model_name "<type>/<language>/<dataset>/<model_name>" --out_path folder/to/save/output.wav
66
+ ```
67
+
68
+ ### 👑 Model contributors
69
+
70
+ - <a href="https://github.com/nmstoker/">@nmstoker</a>
71
+ - <a href="https://github.com/kaiidams/">@kaiidams</a>
72
+ - <a href="https://github.com/WeberJulian/">@WeberJulian,</a>
73
+ - <a href="https://github.com/Edresson/">@Edresson</a>
74
+ - <a href="https://github.com/thorstenMueller/">@thorstenMueller</a>
75
+ - <a href="https://github.com/r-dh/">@r-dh</a>
76
+ - <a href="https://github.com/kirianguiller/">@kirianguiller</a>
77
+ - <a href="https://github.com/robinhad/">@robinhad</a>
78
+
79
+ Drop a ✨PR✨ on 🐸TTS to share a new model and have it included here.
80
+ """
81
+
82
+ iface = gr.Interface(
83
+ fn=tts,
84
+ inputs=[
85
+ gr.inputs.Textbox(
86
+ label="Input",
87
+ default="Hello, how are you?",
88
+ ),
89
+ gr.inputs.Radio(
90
+ label="Pick a TTS Model",
91
+ choices=MODEL_NAMES,
92
+ ),
93
+ # gr.inputs.Dropdown(label="Select a speaker", choices=SPEAKERS, default=None)
94
+ # gr.inputs.Audio(source="microphone", label="Record your voice.", type="numpy", label=None, optional=False)
95
+ ],
96
+ outputs=gr.outputs.Audio(label="Output"),
97
+ title="🐸💬 CoquiTTS Demo",
98
+ theme="grass",
99
+ description="🐸💬 Coqui TTS - a deep learning toolkit for Text-to-Speech, battle-tested in research and production.",
100
+ article=article,
101
+ allow_flagging=False,
102
+ flagging_options=['error', 'bad-quality', 'wrong-pronounciation'],
103
+ live=False
104
+ )
105
+ iface.launch(share=False)
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ libsndfile1
requirments.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ TTS==0.5.0