Update app.py
Browse files
app.py
CHANGED
@@ -92,7 +92,7 @@ CHOICES = {
|
|
92 |
'🇺🇸 🚺 Alloy': 'af_alloy',
|
93 |
'🇺🇸 🚺 Jessica': 'af_jessica',
|
94 |
'🇺🇸 🚺 River': 'af_river',
|
95 |
-
|
96 |
'🇺🇸 🚹 Michael': 'am_michael',
|
97 |
'🇺🇸 🚹 Fenrir': 'am_fenrir',
|
98 |
'🇺🇸 🚹 Puck': 'am_puck',
|
@@ -102,46 +102,46 @@ CHOICES = {
|
|
102 |
'🇺🇸 🚹 Onyx': 'am_onyx',
|
103 |
'🇺🇸 🚹 Santa': 'am_santa',
|
104 |
'🇺🇸 🚹 Adam': 'am_adam',
|
105 |
-
|
106 |
'🇬🇧 🚺 Emma': 'bf_emma',
|
107 |
'🇬🇧 🚺 Isabella': 'bf_isabella',
|
108 |
'🇬🇧 🚺 Alice': 'bf_alice',
|
109 |
'🇬🇧 🚺 Lily': 'bf_lily',
|
110 |
-
|
111 |
'🇬🇧 🚹 George': 'bm_george',
|
112 |
'🇬🇧 🚹 Fable': 'bm_fable',
|
113 |
'🇬🇧 🚹 Lewis': 'bm_lewis',
|
114 |
'🇬🇧 🚹 Daniel': 'bm_daniel',
|
115 |
-
|
116 |
'🇪🇸 🚺 Dora': 'ef_dora',
|
117 |
-
|
118 |
'🇪🇸 🚹 Alex': 'em_alex',
|
119 |
'🇪🇸 🚹 Santa': 'em_santa',
|
120 |
-
|
121 |
'🇫🇷 🚺 Siwis': 'ff_siwis',
|
122 |
-
|
123 |
'🇮🇳 🚹 Alpha': 'hf_alpha',
|
124 |
'🇮🇳 🚹 Beta': 'hf_beta',
|
125 |
-
|
126 |
'🇮🇳 🚹 Omega': 'hm_omega',
|
127 |
'🇮🇳 🚹 Psi': 'hm_psi',
|
128 |
-
|
129 |
'🇮🇹 🚺 Sara': 'if_sara',
|
130 |
-
|
131 |
'🇮🇹 🚺 Nicola': 'im_nicola',
|
132 |
-
|
133 |
'🇯🇵 🚹 Alpha': 'jf_alpha',
|
134 |
'🇯🇵 🚹 Gongitsune': 'jf_gongitsune',
|
135 |
'🇯🇵 🚹 Nezumi': 'jf_nezumi',
|
136 |
'🇯🇵 🚹 Tebukuro': 'jf_tebukuro',
|
137 |
-
|
138 |
'🇯🇵 🚹 Kumo': 'jm_kumo',
|
139 |
-
|
140 |
'🇧🇷 🚺 Dora': 'pf_dora',
|
141 |
-
|
142 |
'🇧🇷 🚹 Alex': 'pm_alex',
|
143 |
'🇧🇷 🚹 Santa': 'pm_santa',
|
144 |
-
|
145 |
'🇨🇳 🚺 Xiaobei': 'zf_xiaobei',
|
146 |
'🇨🇳 🚺 Xiaoni': 'zf_xiaoni',
|
147 |
'🇨🇳 🚺 Xiaoxiao': 'zf_xiaoxiao',
|
@@ -155,12 +155,23 @@ CHOICES = {
|
|
155 |
for v in CHOICES.values():
|
156 |
pipelines[v[0]].load_voice(v)
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
with gr.Blocks() as generate_tab:
|
159 |
out_audio = gr.Audio(label='Output Audio', interactive=False, streaming=False, autoplay=True)
|
160 |
generate_btn = gr.Button('Generate', variant='primary')
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
-
|
163 |
-
STREAM_NOTE = ['⚠️ There is an unknown Gradio bug that might yield no audio the first time you click `Stream`.']
|
164 |
if CHAR_LIMIT is not None:
|
165 |
STREAM_NOTE.append(f'✂️ Each stream is capped at {CHAR_LIMIT} characters.')
|
166 |
STREAM_NOTE.append('🚀 Want more characters? You can [use Kokoro directly](https://huggingface.co/hexgrad/Kokoro-82M#usage) or duplicate this space:')
|
@@ -202,9 +213,11 @@ with gr.Blocks() as app:
|
|
202 |
with gr.Column():
|
203 |
gr.TabbedInterface([generate_tab, stream_tab], ['Generate', 'Stream'])
|
204 |
random_btn.click(fn=get_random_text, inputs=[voice], outputs=[text], api_name=API_NAME)
|
205 |
-
generate_btn.click(fn=generate_first, inputs=[text, voice, speed, use_gpu], outputs=[out_audio], api_name=API_NAME)
|
|
|
206 |
stream_event = stream_btn.click(fn=generate_all, inputs=[text, voice, speed, use_gpu], outputs=[out_stream], api_name=API_NAME)
|
207 |
stop_btn.click(fn=None, cancels=stream_event)
|
|
|
208 |
|
209 |
if __name__ == '__main__':
|
210 |
-
app.queue(api_open=API_OPEN).launch(show_api=API_OPEN, ssr_mode=True)
|
|
|
92 |
'🇺🇸 🚺 Alloy': 'af_alloy',
|
93 |
'🇺🇸 🚺 Jessica': 'af_jessica',
|
94 |
'🇺🇸 🚺 River': 'af_river',
|
95 |
+
|
96 |
'🇺🇸 🚹 Michael': 'am_michael',
|
97 |
'🇺🇸 🚹 Fenrir': 'am_fenrir',
|
98 |
'🇺🇸 🚹 Puck': 'am_puck',
|
|
|
102 |
'🇺🇸 🚹 Onyx': 'am_onyx',
|
103 |
'🇺🇸 🚹 Santa': 'am_santa',
|
104 |
'🇺🇸 🚹 Adam': 'am_adam',
|
105 |
+
|
106 |
'🇬🇧 🚺 Emma': 'bf_emma',
|
107 |
'🇬🇧 🚺 Isabella': 'bf_isabella',
|
108 |
'🇬🇧 🚺 Alice': 'bf_alice',
|
109 |
'🇬🇧 🚺 Lily': 'bf_lily',
|
110 |
+
|
111 |
'🇬🇧 🚹 George': 'bm_george',
|
112 |
'🇬🇧 🚹 Fable': 'bm_fable',
|
113 |
'🇬🇧 🚹 Lewis': 'bm_lewis',
|
114 |
'🇬🇧 🚹 Daniel': 'bm_daniel',
|
115 |
+
|
116 |
'🇪🇸 🚺 Dora': 'ef_dora',
|
117 |
+
|
118 |
'🇪🇸 🚹 Alex': 'em_alex',
|
119 |
'🇪🇸 🚹 Santa': 'em_santa',
|
120 |
+
|
121 |
'🇫🇷 🚺 Siwis': 'ff_siwis',
|
122 |
+
|
123 |
'🇮🇳 🚹 Alpha': 'hf_alpha',
|
124 |
'🇮🇳 🚹 Beta': 'hf_beta',
|
125 |
+
|
126 |
'🇮🇳 🚹 Omega': 'hm_omega',
|
127 |
'🇮🇳 🚹 Psi': 'hm_psi',
|
128 |
+
|
129 |
'🇮🇹 🚺 Sara': 'if_sara',
|
130 |
+
|
131 |
'🇮🇹 🚺 Nicola': 'im_nicola',
|
132 |
+
|
133 |
'🇯🇵 🚹 Alpha': 'jf_alpha',
|
134 |
'🇯🇵 🚹 Gongitsune': 'jf_gongitsune',
|
135 |
'🇯🇵 🚹 Nezumi': 'jf_nezumi',
|
136 |
'🇯🇵 🚹 Tebukuro': 'jf_tebukuro',
|
137 |
+
|
138 |
'🇯🇵 🚹 Kumo': 'jm_kumo',
|
139 |
+
|
140 |
'🇧🇷 🚺 Dora': 'pf_dora',
|
141 |
+
|
142 |
'🇧🇷 🚹 Alex': 'pm_alex',
|
143 |
'🇧🇷 🚹 Santa': 'pm_santa',
|
144 |
+
|
145 |
'🇨🇳 🚺 Xiaobei': 'zf_xiaobei',
|
146 |
'🇨🇳 🚺 Xiaoni': 'zf_xiaoni',
|
147 |
'🇨🇳 🚺 Xiaoxiao': 'zf_xiaoxiao',
|
|
|
155 |
for v in CHOICES.values():
|
156 |
pipelines[v[0]].load_voice(v)
|
157 |
|
158 |
+
TOKEN_NOTE = '''
|
159 |
+
💡 Customize pronunciation with Markdown link syntax and /slashes/ like [Kokoro](/kˈOkəɹO/)
|
160 |
+
💬 To adjust intonation, try punctuation ;:,.!?—…"()“” or stress ˈ and ˌ
|
161 |
+
⬇️ Lower stress [1 level](-1) or [2 levels](-2)
|
162 |
+
⬆️ Raise stress 1 level [or](+2) 2 levels (only works on less stressed, usually short words)
|
163 |
+
'''
|
164 |
+
|
165 |
with gr.Blocks() as generate_tab:
|
166 |
out_audio = gr.Audio(label='Output Audio', interactive=False, streaming=False, autoplay=True)
|
167 |
generate_btn = gr.Button('Generate', variant='primary')
|
168 |
+
with gr.Accordion('Output Tokens', open=True):
|
169 |
+
out_ps = gr.Textbox(interactive=False, show_label=False, info='Tokens used to generate the audio, up to 510 context length.')
|
170 |
+
tokenize_btn = gr.Button('Tokenize', variant='secondary')
|
171 |
+
gr.Markdown(TOKEN_NOTE)
|
172 |
+
predict_btn = gr.Button('Predict', variant='secondary', visible=False)
|
173 |
|
174 |
+
STREAM_NOTE = ['⚠️ There is an unknown Gradio bug that might yield no audio the first time you click Stream.']
|
|
|
175 |
if CHAR_LIMIT is not None:
|
176 |
STREAM_NOTE.append(f'✂️ Each stream is capped at {CHAR_LIMIT} characters.')
|
177 |
STREAM_NOTE.append('🚀 Want more characters? You can [use Kokoro directly](https://huggingface.co/hexgrad/Kokoro-82M#usage) or duplicate this space:')
|
|
|
213 |
with gr.Column():
|
214 |
gr.TabbedInterface([generate_tab, stream_tab], ['Generate', 'Stream'])
|
215 |
random_btn.click(fn=get_random_text, inputs=[voice], outputs=[text], api_name=API_NAME)
|
216 |
+
generate_btn.click(fn=generate_first, inputs=[text, voice, speed, use_gpu], outputs=[out_audio, out_ps], api_name=API_NAME)
|
217 |
+
tokenize_btn.click(fn=tokenize_first, inputs=[text, voice], outputs=[out_ps], api_name=API_NAME)
|
218 |
stream_event = stream_btn.click(fn=generate_all, inputs=[text, voice, speed, use_gpu], outputs=[out_stream], api_name=API_NAME)
|
219 |
stop_btn.click(fn=None, cancels=stream_event)
|
220 |
+
predict_btn.click(fn=predict, inputs=[text, voice, speed], outputs=[out_audio], api_name=API_NAME)
|
221 |
|
222 |
if __name__ == '__main__':
|
223 |
+
app.queue(api_open=API_OPEN).launch(show_api=API_OPEN, ssr_mode=True)
|