ZDisket commited on
Commit
0a779e7
·
verified ·
1 Parent(s): 0f43681

Remove stale style text input

Browse files
Files changed (1) hide show
  1. app.py +8 -21
app.py CHANGED
@@ -248,7 +248,6 @@ def _random_text() -> str:
248
  @spaces.GPU
249
  def synthesize(
250
  text: str,
251
- style_text: str,
252
  language: str,
253
  speaker_label: str,
254
  emotion_label: str,
@@ -262,7 +261,6 @@ def synthesize(
262
 
263
  Args:
264
  text: The text to synthesize.
265
- style_text: Optional style reference text (falls back to ``text``).
266
  language: Language code (e.g. ``"en"``).
267
  speaker_label: Speaker name from the dropdown.
268
  emotion_label: Emotion name from the dropdown.
@@ -276,11 +274,6 @@ def synthesize(
276
  A tuple of (wav_filepath, stats_json).
277
  """
278
  clean_text = normalize_client_text(text, max_chars=MAX_TEXT_CHARS)
279
- clean_style_text = (
280
- normalize_client_text(style_text, max_chars=MAX_TEXT_CHARS)
281
- if style_text and style_text.strip()
282
- else ""
283
- )
284
  clean_language = normalize_language(language)
285
  if speaker_label not in SPEAKER_IDS:
286
  raise gr.Error("Choose a valid speaker.")
@@ -309,7 +302,7 @@ def synthesize(
309
  audio_top_k=clean_top_k if clean_top_k > 0 else None,
310
  audio_repetition_penalty=clean_rep_pen,
311
  n_vq_for_inference=32,
312
- style_text=clean_style_text or clean_text,
313
  style_emotion_id=emotion_lookup[emotion_label],
314
  style_energy=clean_energy,
315
  )
@@ -373,12 +366,6 @@ with gr.Blocks(
373
  lines=4,
374
  max_length=MAX_TEXT_CHARS,
375
  )
376
- style_text = gr.Textbox(
377
- label="Style text (optional)",
378
- placeholder="Leave empty to use the same text as input.",
379
- lines=2,
380
- max_length=MAX_TEXT_CHARS,
381
- )
382
  with gr.Row():
383
  randomize = gr.Button("Random Text")
384
  generate = gr.Button("Generate", variant="primary")
@@ -430,17 +417,17 @@ with gr.Blocks(
430
 
431
  gr.Examples(
432
  examples=[
433
- ["I wasn't expecting that to work, but now I'm kind of excited.", "", "en",
434
  DEFAULT_SPEAKER, "Neutral", 0.5, 0.8, 0.92, 0, 1.05],
435
- ["You have no idea how happy that made me.", "", "en",
436
  DEFAULT_SPEAKER, "Happy", 0.8, 0.8, 0.92, 0, 1.05],
437
- ["I'm trying to stay calm, but that was way closer than I expected.", "", "en",
438
  DEFAULT_SPEAKER, "Fearful", 0.3, 0.8, 0.92, 0, 1.05],
439
- ["Okay, deep breath. We can fix this if we take it one step at a time.", "", "en",
440
  DEFAULT_SPEAKER, "Calm", 0.4, 0.8, 0.92, 0, 1.05],
441
  ],
442
  inputs=[
443
- text, style_text, language, speaker, emotion, style_energy,
444
  audio_temperature, audio_top_p, audio_top_k, audio_repetition_penalty,
445
  ],
446
  outputs=[audio_output, stats],
@@ -453,7 +440,7 @@ with gr.Blocks(
453
  generate.click(
454
  synthesize,
455
  inputs=[
456
- text, style_text, language, speaker, emotion, style_energy,
457
  audio_temperature, audio_top_p, audio_top_k, audio_repetition_penalty,
458
  ],
459
  outputs=[audio_output, stats],
@@ -462,4 +449,4 @@ with gr.Blocks(
462
 
463
  if __name__ == "__main__":
464
  demo.queue(default_concurrency_limit=1, max_size=20)
465
- demo.launch(mcp_server=True, show_error=False)
 
248
  @spaces.GPU
249
  def synthesize(
250
  text: str,
 
251
  language: str,
252
  speaker_label: str,
253
  emotion_label: str,
 
261
 
262
  Args:
263
  text: The text to synthesize.
 
264
  language: Language code (e.g. ``"en"``).
265
  speaker_label: Speaker name from the dropdown.
266
  emotion_label: Emotion name from the dropdown.
 
274
  A tuple of (wav_filepath, stats_json).
275
  """
276
  clean_text = normalize_client_text(text, max_chars=MAX_TEXT_CHARS)
 
 
 
 
 
277
  clean_language = normalize_language(language)
278
  if speaker_label not in SPEAKER_IDS:
279
  raise gr.Error("Choose a valid speaker.")
 
302
  audio_top_k=clean_top_k if clean_top_k > 0 else None,
303
  audio_repetition_penalty=clean_rep_pen,
304
  n_vq_for_inference=32,
305
+ style_text=clean_text,
306
  style_emotion_id=emotion_lookup[emotion_label],
307
  style_energy=clean_energy,
308
  )
 
366
  lines=4,
367
  max_length=MAX_TEXT_CHARS,
368
  )
 
 
 
 
 
 
369
  with gr.Row():
370
  randomize = gr.Button("Random Text")
371
  generate = gr.Button("Generate", variant="primary")
 
417
 
418
  gr.Examples(
419
  examples=[
420
+ ["I wasn't expecting that to work, but now I'm kind of excited.", "en",
421
  DEFAULT_SPEAKER, "Neutral", 0.5, 0.8, 0.92, 0, 1.05],
422
+ ["You have no idea how happy that made me.", "en",
423
  DEFAULT_SPEAKER, "Happy", 0.8, 0.8, 0.92, 0, 1.05],
424
+ ["I'm trying to stay calm, but that was way closer than I expected.", "en",
425
  DEFAULT_SPEAKER, "Fearful", 0.3, 0.8, 0.92, 0, 1.05],
426
+ ["Okay, deep breath. We can fix this if we take it one step at a time.", "en",
427
  DEFAULT_SPEAKER, "Calm", 0.4, 0.8, 0.92, 0, 1.05],
428
  ],
429
  inputs=[
430
+ text, language, speaker, emotion, style_energy,
431
  audio_temperature, audio_top_p, audio_top_k, audio_repetition_penalty,
432
  ],
433
  outputs=[audio_output, stats],
 
440
  generate.click(
441
  synthesize,
442
  inputs=[
443
+ text, language, speaker, emotion, style_energy,
444
  audio_temperature, audio_top_p, audio_top_k, audio_repetition_penalty,
445
  ],
446
  outputs=[audio_output, stats],
 
449
 
450
  if __name__ == "__main__":
451
  demo.queue(default_concurrency_limit=1, max_size=20)
452
+ demo.launch(mcp_server=True, show_error=False)