zach commited on
Commit
ae60c0f
·
1 Parent(s): f076d8d

Update UI layout and improve instructions content

Browse files
Files changed (1) hide show
  1. src/app.py +47 -34
src/app.py CHANGED
@@ -288,15 +288,16 @@ class App:
288
  value=None,
289
  interactive=True,
290
  )
291
- character_description_input = gr.Textbox(
292
- label="Character Description",
293
- placeholder="Enter a character description...",
294
- lines=3,
295
- max_lines=8,
296
- max_length=constants.CHARACTER_DESCRIPTION_MAX_LENGTH,
297
- show_copy_button=True,
298
- )
299
- generate_text_button = gr.Button("Generate Text", variant="secondary")
 
300
  return (
301
  sample_character_description_dropdown,
302
  character_description_input,
@@ -307,17 +308,18 @@ class App:
307
  """
308
  Builds the output section including text input, audio players, and vote buttons.
309
  """
310
- text_input = gr.Textbox(
311
- label="Input Text",
312
- placeholder="Enter or generate text for synthesis...",
313
- interactive=True,
314
- autoscroll=False,
315
- lines=3,
316
- max_lines=8,
317
- max_length=constants.CHARACTER_DESCRIPTION_MAX_LENGTH,
318
- show_copy_button=True,
319
- )
320
- synthesize_speech_button = gr.Button("Synthesize Speech", variant="primary")
 
321
 
322
  with gr.Row(equal_height=True):
323
  with gr.Column():
@@ -364,30 +366,42 @@ class App:
364
  fill_width=True,
365
  css_paths="src/assets/styles.css",
366
  ) as demo:
367
- # Title & instructions
368
  gr.Markdown("# Expressive TTS Arena")
369
- gr.Markdown(
 
370
  """
371
- 1. **Choose or enter a character description**: Select a sample from the list or enter your own to guide
372
- text and voice generation.
373
- 2. **Generate text**: Click **"Generate Text"** to create dialogue based on the character. The generated
374
- text will appear in the input field automatically—edit it if needed.
375
- 3. **Synthesize speech**: Click **"Synthesize Speech"** to send your text and character description to
376
- two TTS APIs. Each API generates a voice and synthesizes speech in that voice.
377
- 4. **Listen & compare**: Play both audio options and assess their expressiveness.
378
- 5. **Vote for the best**: Click **"Select Option A"** or **"Select Option B"** to choose the most
379
- expressive output.
 
 
 
 
 
 
 
 
 
 
 
 
 
380
  """
381
  )
382
 
383
- # Build generate text section
384
  (
385
  sample_character_description_dropdown,
386
  character_description_input,
387
  generate_text_button,
388
  ) = self._build_input_section()
389
 
390
- # Build synthesize speech section
391
  (
392
  text_input,
393
  synthesize_speech_button,
@@ -412,7 +426,6 @@ class App:
412
  vote_submitted_state = gr.State(False)
413
 
414
  # --- Register event handlers ---
415
-
416
  # When a sample character description is chosen, update the character description textbox
417
  sample_character_description_dropdown.change(
418
  fn=lambda choice: constants.SAMPLE_CHARACTER_DESCRIPTIONS.get(choice, ""),
 
288
  value=None,
289
  interactive=True,
290
  )
291
+ with gr.Group():
292
+ character_description_input = gr.Textbox(
293
+ label="Character Description",
294
+ placeholder="Enter a character description...",
295
+ lines=3,
296
+ max_lines=8,
297
+ max_length=constants.CHARACTER_DESCRIPTION_MAX_LENGTH,
298
+ show_copy_button=True,
299
+ )
300
+ generate_text_button = gr.Button("Generate Text", variant="secondary")
301
  return (
302
  sample_character_description_dropdown,
303
  character_description_input,
 
308
  """
309
  Builds the output section including text input, audio players, and vote buttons.
310
  """
311
+ with gr.Group():
312
+ text_input = gr.Textbox(
313
+ label="Input Text",
314
+ placeholder="Enter or generate text for synthesis...",
315
+ interactive=True,
316
+ autoscroll=False,
317
+ lines=3,
318
+ max_lines=8,
319
+ max_length=constants.CHARACTER_DESCRIPTION_MAX_LENGTH,
320
+ show_copy_button=True,
321
+ )
322
+ synthesize_speech_button = gr.Button("Synthesize Speech", variant="primary")
323
 
324
  with gr.Row(equal_height=True):
325
  with gr.Column():
 
366
  fill_width=True,
367
  css_paths="src/assets/styles.css",
368
  ) as demo:
369
+ # --- UI components ---
370
  gr.Markdown("# Expressive TTS Arena")
371
+
372
+ gr.HTML(
373
  """
374
+ <p><strong>Instructions</strong></p>
375
+ <ol style="margin-left: 8px;">
376
+ <li>
377
+ Choose or enter a character description by selecting a sample or typing your own to guide
378
+ text generation and voice synthesis.
379
+ </li>
380
+ <li>
381
+ Click the <strong>"Generate Text"</strong> button to create dialogue for the character;
382
+ the text automatically populates the input field for further editing.
383
+ </li>
384
+ <li>
385
+ Click the <strong>"Synthesize Speech"</strong> button to convert your text and character
386
+ description into two synthesized speech options for direct comparison.
387
+ </li>
388
+ <li>
389
+ Listen to both audio outputs to assess their expressiveness.
390
+ </li>
391
+ <li>
392
+ Click <strong>"Select Option A"</strong> or <strong>"Select Option B"</strong> to vote for
393
+ the most expressive result.
394
+ </li>
395
+ </ol>
396
  """
397
  )
398
 
 
399
  (
400
  sample_character_description_dropdown,
401
  character_description_input,
402
  generate_text_button,
403
  ) = self._build_input_section()
404
 
 
405
  (
406
  text_input,
407
  synthesize_speech_button,
 
426
  vote_submitted_state = gr.State(False)
427
 
428
  # --- Register event handlers ---
 
429
  # When a sample character description is chosen, update the character description textbox
430
  sample_character_description_dropdown.change(
431
  fn=lambda choice: constants.SAMPLE_CHARACTER_DESCRIPTIONS.get(choice, ""),