shukdevdatta123 commited on
Commit
2962129
·
verified ·
1 Parent(s): 8eb4a72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -22
app.py CHANGED
@@ -157,7 +157,7 @@ for v in CHOICES.values():
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
  '''
@@ -165,26 +165,30 @@ TOKEN_NOTE = '''
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:')
178
- STREAM_NOTE = '\n\n'.join(STREAM_NOTE)
179
-
180
- with gr.Blocks() as stream_tab:
181
- out_stream = gr.Audio(label='Output Audio Stream', interactive=False, streaming=True, autoplay=True)
182
- with gr.Row():
183
- stream_btn = gr.Button('Stream', variant='primary')
184
- stop_btn = gr.Button('Stop', variant='stop')
185
- with gr.Accordion('Note', open=True):
186
- gr.Markdown(STREAM_NOTE)
187
- gr.DuplicateButton()
 
188
 
189
  BANNER_TEXT = '''
190
  [***Kokoro*** **is an open-weight TTS model with 82 million parameters.**](https://huggingface.co/hexgrad/Kokoro-82M)
@@ -211,13 +215,11 @@ with gr.Blocks() as app:
211
  speed = gr.Slider(minimum=0.5, maximum=2, value=1, step=0.1, label='Speed')
212
  random_btn = gr.Button('Random Text', variant='secondary')
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)
 
157
 
158
  TOKEN_NOTE = '''
159
  💡 Customize pronunciation with Markdown link syntax and /slashes/ like `[Kokoro](/kˈOkəɹO/)`
160
+ 💬 To adjust intonation, try punctuation `;:,.!?—…"()“”`
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
  '''
 
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
+
169
+ # Commenting out the Output Tokens and Stream Tab sections
170
+ '''
171
  with gr.Accordion('Output Tokens', open=True):
172
  out_ps = gr.Textbox(interactive=False, show_label=False, info='Tokens used to generate the audio, up to 510 context length.')
173
  tokenize_btn = gr.Button('Tokenize', variant='secondary')
174
  gr.Markdown(TOKEN_NOTE)
175
  predict_btn = gr.Button('Predict', variant='secondary', visible=False)
176
 
177
+ STREAM_NOTE = ['⚠️ There is an unknown Gradio bug that might yield no audio the first time you click `Stream`.']
178
+ if CHAR_LIMIT is not None:
179
+ STREAM_NOTE.append(f'✂️ Each stream is capped at {CHAR_LIMIT} characters.')
180
+ STREAM_NOTE.append('🚀 Want more characters? You can [use Kokoro directly](https://huggingface.co/hexgrad/Kokoro-82M#usage) or duplicate this space:')
181
+ STREAM_NOTE = '\n\n'.join(STREAM_NOTE)
182
+
183
+ with gr.Blocks() as stream_tab:
184
+ out_stream = gr.Audio(label='Output Audio Stream', interactive=False, streaming=True, autoplay=True)
185
+ with gr.Row():
186
+ stream_btn = gr.Button('Stream', variant='primary')
187
+ stop_btn = gr.Button('Stop', variant='stop')
188
+ with gr.Accordion('Note', open=True):
189
+ gr.Markdown(STREAM_NOTE)
190
+ gr.DuplicateButton()
191
+ '''
192
 
193
  BANNER_TEXT = '''
194
  [***Kokoro*** **is an open-weight TTS model with 82 million parameters.**](https://huggingface.co/hexgrad/Kokoro-82M)
 
215
  speed = gr.Slider(minimum=0.5, maximum=2, value=1, step=0.1, label='Speed')
216
  random_btn = gr.Button('Random Text', variant='secondary')
217
  with gr.Column():
218
+ # Only keeping the Generate tab active
219
+ generate_btn.click(fn=generate_first, inputs=[text, voice, speed, use_gpu], outputs=[out_audio, out_ps], api_name=API_NAME)
220
+ tokenize_btn.click(fn=tokenize_first, inputs=[text, voice], outputs=[out_ps], api_name=API_NAME)
221
+
222
  random_btn.click(fn=get_random_text, inputs=[voice], outputs=[text], api_name=API_NAME)
 
 
 
 
 
223
 
224
  if __name__ == '__main__':
225
+ app.queue(api_open=API_OPEN).launch(show_api=API_OPEN, ssr_mode=True)