Eren Gรถlge commited on
Commit
a3635dc
โ€ข
1 Parent(s): 8f9ad5e
Files changed (1) hide show
  1. app.py +114 -62
app.py CHANGED
@@ -28,7 +28,7 @@ MODEL_NAMES = EN + OTHER
28
  print(MODEL_NAMES)
29
 
30
 
31
- def tts(text: str, model_name: str, speaker_idx: str=None):
32
  if len(text) > MAX_TXT_LEN:
33
  text = text[:MAX_TXT_LEN]
34
  print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
@@ -48,72 +48,124 @@ def tts(text: str, model_name: str, speaker_idx: str=None):
48
  # synthesize
49
  if synthesizer is None:
50
  raise NameError("model not found")
51
- wavs = synthesizer.tts(text, speaker_idx)
52
  # return output
53
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
54
  synthesizer.save_wav(wavs, fp)
55
  return fp.name
56
 
57
 
58
-
59
- article= """
60
- Visit us on Coqui.ai and drop a ๐ŸŒŸ to ๐Ÿ”—<a href="https://github.com/coqui-ai/TTS" target="_blank">CoquiTTS</a>.
61
-
62
- <br/>
63
-
64
- Run CoquiTTS locally for the best result. Check out our ๐Ÿ”—<a href="https://tts.readthedocs.io/en/latest/inference.html">documentation</a>.
65
-
66
- ```bash
67
- $ pip install TTS
68
- ...
69
- $ tts --list_models
70
- ...
71
- $ tts --text "Text for TTS" --model_name "<type>/<language>/<dataset>/<model_name>" --out_path folder/to/save/output.wav
72
- ```
73
- <img src="https://static.scarf.sh/a.png?x-pxid=1404a024-e647-4406-bb9a-4ade0c931182" />
74
- <br/>
75
-
76
- ๐Ÿ‘‘ <b> Model contributors</b>
77
-
78
- - <a href="https://github.com/nmstoker/" target="_blank">@nmstoker</a>
79
- - <a href="https://github.com/kaiidams/" target="_blank">@kaiidams</a>
80
- - <a href="https://github.com/WeberJulian/" target="_blank">@WeberJulian,</a>
81
- - <a href="https://github.com/Edresson/" target="_blank">@Edresson</a>
82
- - <a href="https://github.com/thorstenMueller/" target="_blank">@thorstenMueller</a>
83
- - <a href="https://github.com/r-dh/" target="_blank">@r-dh</a>
84
- - <a href="https://github.com/kirianguiller/" target="_blank">@kirianguiller</a>
85
- - <a href="https://github.com/robinhad/" target="_blank">@robinhad</a>
86
- - <a href="https://github.com/fkarabiber/" target="_blank">@fkarabiber</a>
87
- - <a href="https://github.com/nicolalandro/" target="_blank">@nicolalandro</a>
88
- - <a href="https://github.com/a-froghyar" target="_blank">@a-froghyar</a>
89
- - <a href="https://github.com/manmay-nakhashi" target="_blank">@manmay-nakhashi</a>
90
- - <a href="https://github.com/noml4u" target="_blank">@noml4u</a>
91
-
92
- ๐Ÿ‘‰ Drop a โœจPRโœจ on ๐ŸธTTS to share a new model and have it included here.
93
  """
94
 
95
- iface = gr.Interface(
96
- fn=tts,
97
- inputs=[
98
- gr.inputs.Textbox(
99
- label="Input Text",
100
- default="This sentence has been generated by a speech synthesis system.",
101
- ),
102
- gr.inputs.Radio(
103
- label="Pick a TTS Model - (language/dataset/model_name)",
104
- choices=MODEL_NAMES,
105
- ),
106
- # gr.inputs.Dropdown(label="Select a speaker", choices=SPEAKERS, default=None)
107
- # gr.inputs.Audio(source="microphone", label="Record your voice.", type="numpy", label=None, optional=False)
108
- ],
109
- outputs=gr.outputs.Audio(label="Output"),
110
- title="๐Ÿธ๐Ÿ’ฌ CoquiTTS Demo",
111
- theme="grass",
112
- description="๐Ÿธ๐Ÿ’ฌ Coqui TTS - a deep learning toolkit for Text-to-Speech, battle-tested in research and production.",
113
- article=article,
114
- allow_flagging=False,
115
- flagging_options=['error', 'bad-quality', 'wrong-pronounciation'],
116
- layout="vertical",
117
- live=False
118
- )
119
- iface.launch(share=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  print(MODEL_NAMES)
29
 
30
 
31
+ def tts(text: str, model_name: str):
32
  if len(text) > MAX_TXT_LEN:
33
  text = text[:MAX_TXT_LEN]
34
  print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
 
48
  # synthesize
49
  if synthesizer is None:
50
  raise NameError("model not found")
51
+ wavs = synthesizer.tts(text, None)
52
  # return output
53
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
54
  synthesizer.save_wav(wavs, fp)
55
  return fp.name
56
 
57
 
58
+ title = """<h1 align="center">๐Ÿธ๐Ÿ’ฌ CoquiTTS Playground </h1>"""
59
+ custom_css = """
60
+ #banner-image {
61
+ display: block;
62
+ margin-left: auto;
63
+ margin-right: auto;
64
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  """
66
 
67
+ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
68
+ with gr.Row():
69
+ with gr.Column():
70
+ # gr.Image("https://raw.githubusercontent.com/coqui-ai/TTS/main/images/coqui-log-green-TTS.png", elem_id="banner-image", show_label=False)
71
+ gr.Markdown(
72
+ """
73
+ ## <img src="https://raw.githubusercontent.com/coqui-ai/TTS/main/images/coqui-log-green-TTS.png" height="56"/>
74
+ """
75
+ )
76
+ gr.Markdown(
77
+ """
78
+ <br />
79
+
80
+ ## ๐ŸธCoqui.ai News
81
+ - ๐Ÿ“ฃ ๐ŸธTTS now supports ๐ŸขTortoise with faster inference.
82
+ - ๐Ÿ“ฃ **Coqui Studio API** is landed on ๐ŸธTTS. - [Example](https://github.com/coqui-ai/TTS/blob/dev/README.md#-python-api)
83
+ - ๐Ÿ“ฃ [**Coqui Sudio API**](https://docs.coqui.ai/docs) is live.
84
+ - ๐Ÿ“ฃ Voice generation with prompts - **Prompt to Voice** - is live on [**Coqui Studio**](https://app.coqui.ai/auth/signin)!! - [Blog Post](https://coqui.ai/blog/tts/prompt-to-voice)
85
+ - ๐Ÿ“ฃ Voice generation with fusion - **Voice fusion** - is live on [**Coqui Studio**](https://app.coqui.ai/auth/signin).
86
+ - ๐Ÿ“ฃ Voice cloning is live on [**Coqui Studio**](https://app.coqui.ai/auth/signin).
87
+ <br>
88
+
89
+ """
90
+ )
91
+ with gr.Column():
92
+ gr.Markdown(
93
+ """
94
+ <br/>
95
+
96
+ ๐Ÿ’ป This space showcases some of the **[CoquiTTS](https://github.com/coqui-ai/TTS)** models.
97
+
98
+ <br/>
99
+
100
+ There are > 30 languages with single and multi speaker models, all thanks to our ๐Ÿ‘‘ Contributors.
101
+
102
+ <br/>
103
+
104
+ Visit the links below for more.
105
+
106
+ | | |
107
+ | ------------------------------- | --------------------------------------- |
108
+ | ๐Ÿธ๐Ÿ’ฌ **CoquiTTS** | [Github](https://github.com/coqui-ai/TTS) |
109
+ | ๐Ÿ’ผ **Documentation** | [ReadTheDocs](https://tts.readthedocs.io/en/latest/)
110
+ | ๐Ÿ‘ฉโ€๐Ÿ’ป **Questions** | [GitHub Discussions] |
111
+ | ๐Ÿ—ฏ **Community** | [![Dicord](https://img.shields.io/discord/1037326658807533628?color=%239B59B6&label=chat%20on%20discord)](https://discord.gg/5eXr5seRrv) |
112
+
113
+ [github issue tracker]: https://github.com/coqui-ai/tts/issues
114
+ [github discussions]: https://github.com/coqui-ai/TTS/discussions
115
+ [discord]: https://discord.gg/5eXr5seRrv
116
+
117
+
118
+ """
119
+ )
120
+
121
+ with gr.Row():
122
+ gr.Markdown(
123
+ """
124
+ <details>
125
+ <summary>๐Ÿ‘‘ Model contributors</summary>
126
+
127
+ - <a href="https://github.com/nmstoker/" target="_blank">@nmstoker</a>
128
+ - <a href="https://github.com/kaiidams/" target="_blank">@kaiidams</a>
129
+ - <a href="https://github.com/WeberJulian/" target="_blank">@WeberJulian,</a>
130
+ - <a href="https://github.com/Edresson/" target="_blank">@Edresson</a>
131
+ - <a href="https://github.com/thorstenMueller/" target="_blank">@thorstenMueller</a>
132
+ - <a href="https://github.com/r-dh/" target="_blank">@r-dh</a>
133
+ - <a href="https://github.com/kirianguiller/" target="_blank">@kirianguiller</a>
134
+ - <a href="https://github.com/robinhad/" target="_blank">@robinhad</a>
135
+ - <a href="https://github.com/fkarabiber/" target="_blank">@fkarabiber</a>
136
+ - <a href="https://github.com/nicolalandro/" target="_blank">@nicolalandro</a>
137
+ - <a href="https://github.com/a-froghyar" target="_blank">@a-froghyar</a>
138
+ - <a href="https://github.com/manmay-nakhashi" target="_blank">@manmay-nakhashi</a>
139
+ - <a href="https://github.com/noml4u" target="_blank">@noml4u</a>
140
+ </details>
141
+
142
+ <br/>
143
+ """
144
+ )
145
+
146
+ with gr.Row():
147
+ with gr.Column():
148
+ input_text = gr.inputs.Textbox(
149
+ label="Input Text",
150
+ default="This sentence has been generated by a speech synthesis system.",
151
+ )
152
+ model_select = gr.inputs.Dropdown(
153
+ label="Pick Model: tts_models/<language>/<dataset>/<model_name>",
154
+ choices=MODEL_NAMES,
155
+ default="tts_models/en/jenny/jenny"
156
+ )
157
+ tts_button = gr.Button("Send", elem_id="send-btn", visible=True)
158
+
159
+ with gr.Column():
160
+ output_audio = gr.outputs.Audio(label="Output", type="filepath")
161
+
162
+ tts_button.click(
163
+ tts,
164
+ inputs=[
165
+ input_text,
166
+ model_select,
167
+ ],
168
+ outputs=[output_audio],
169
+ )
170
+
171
+ demo.queue(concurrency_count=16).launch(debug=True)