Remsky commited on
Commit
bf1c3fd
·
1 Parent(s): 0fce010

Remove static text from labels in TTS demo and update label formatting

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -234,19 +234,19 @@ with gr.Blocks(title="Kokoro TTS Demo", css="""
234
  tokens = count_tokens(initial_text)
235
  time_estimate = math.ceil(tokens / lab_tps)
236
  output_estimate = (time_estimate * lab_rts)//60
237
- initial_label = f'<div class="token-label">Text to speak <span class="token-count">Estimated {output_estimate} minutes in ~{time_estimate}s</span></div>'
238
  else:
239
- initial_label = '<div class="token-label">Text to speak</div>'
240
  else:
241
- initial_label = '<div class="token-label">Text to speak</div>'
242
 
243
  def update_text_label(text):
244
  if not text:
245
- return '<div class="token-label">Text to speak</div>'
246
  tokens = count_tokens(text)
247
  time_estimate = math.ceil(tokens / lab_tps)
248
  output_estimate = (time_estimate * lab_rts)//60
249
- return f'<div class="token-label">Text to speak <span class="token-count">Estimated {output_estimate} minutes in ~{time_estimate}s</span></div>'
250
 
251
 
252
  text_input = gr.TextArea(
@@ -262,7 +262,7 @@ with gr.Blocks(title="Kokoro TTS Demo", css="""
262
  label_html = gr.HTML(initial_label)
263
 
264
  def clear_text():
265
- return "", '<div class="token-label">Text to speak</div>'
266
 
267
  clear_btn.click(
268
  fn=clear_text,
 
234
  tokens = count_tokens(initial_text)
235
  time_estimate = math.ceil(tokens / lab_tps)
236
  output_estimate = (time_estimate * lab_rts)//60
237
+ initial_label = f'<div class="token-label"><span class="token-count">Estimated {output_estimate} minutes in ~{time_estimate}s</span></div>'
238
  else:
239
+ initial_label = '<div class="token-label"></div>'
240
  else:
241
+ initial_label = '<div class="token-label"></div>'
242
 
243
  def update_text_label(text):
244
  if not text:
245
+ return '<div class="token-label"></div>'
246
  tokens = count_tokens(text)
247
  time_estimate = math.ceil(tokens / lab_tps)
248
  output_estimate = (time_estimate * lab_rts)//60
249
+ return f'<div class="token-label"><span class="token-count">Estimated {output_estimate} minutes in ~{time_estimate}s</span></div>'
250
 
251
 
252
  text_input = gr.TextArea(
 
262
  label_html = gr.HTML(initial_label)
263
 
264
  def clear_text():
265
+ return "", '<div class="token-label"></div>'
266
 
267
  clear_btn.click(
268
  fn=clear_text,