zach commited on
Commit
7f21bab
·
1 Parent(s): ee8b196

Improves UI content for clarity

Browse files
Files changed (3) hide show
  1. src/app.py +16 -15
  2. src/constants.py +2 -2
  3. src/utils.py +0 -5
src/app.py CHANGED
@@ -220,7 +220,7 @@ def vote(
220
  if not option_map or vote_submitted:
221
  return gr.skip(), gr.skip(), gr.skip(), gr.skip()
222
 
223
- option_a_selected = selected_button == constants.VOTE_FOR_OPTION_A
224
  selected_option, other_option = (
225
  (constants.OPTION_A, constants.OPTION_B)
226
  if option_a_selected
@@ -282,8 +282,8 @@ def reset_ui() -> Tuple[gr.update, gr.update, gr.update, gr.update, None, None,
282
  return (
283
  gr.update(value=None),
284
  gr.update(value=None, autoplay=False),
285
- gr.update(value=constants.VOTE_FOR_OPTION_A, variant="secondary"),
286
- gr.update(value=constants.VOTE_FOR_OPTION_B, variant="secondary"),
287
  None,
288
  None,
289
  False,
@@ -299,14 +299,14 @@ def build_input_section() -> Tuple[gr.Dropdown, gr.Textbox, gr.Button]:
299
  interactive=True,
300
  )
301
  character_description_input = gr.Textbox(
302
- label="Character description",
303
  placeholder="Enter a character description...",
304
  lines=3,
305
  max_lines=8,
306
  max_length=constants.CHARACTER_DESCRIPTION_MAX_LENGTH,
307
  show_copy_button=True,
308
  )
309
- generate_text_button = gr.Button("Generate text", variant="secondary")
310
  return (
311
  sample_character_description_dropdown,
312
  character_description_input,
@@ -317,10 +317,10 @@ def build_input_section() -> Tuple[gr.Dropdown, gr.Textbox, gr.Button]:
317
  def build_output_section() -> (
318
  Tuple[gr.Textbox, gr.Button, gr.Audio, gr.Audio, gr.Button, gr.Button]
319
  ):
320
- """Builds the output section including generated text, audio players, and vote buttons."""
321
  text_input = gr.Textbox(
322
- label="Text",
323
- placeholder="Generate or enter text...",
324
  interactive=True,
325
  autoscroll=False,
326
  lines=3,
@@ -328,7 +328,7 @@ def build_output_section() -> (
328
  max_length=constants.CHARACTER_DESCRIPTION_MAX_LENGTH,
329
  show_copy_button=True,
330
  )
331
- synthesize_speech_button = gr.Button("Synthesize speech", variant="primary")
332
  with gr.Row(equal_height=True):
333
  option_a_audio_player = gr.Audio(
334
  label=constants.OPTION_A, type="filepath", interactive=False
@@ -337,8 +337,8 @@ def build_output_section() -> (
337
  label=constants.OPTION_B, type="filepath", interactive=False
338
  )
339
  with gr.Row(equal_height=True):
340
- vote_button_a = gr.Button(constants.VOTE_FOR_OPTION_A, interactive=False)
341
- vote_button_b = gr.Button(constants.VOTE_FOR_OPTION_B, interactive=False)
342
  return (
343
  text_input,
344
  synthesize_speech_button,
@@ -367,10 +367,11 @@ def build_gradio_interface() -> gr.Blocks:
367
  gr.Markdown("# Expressive TTS Arena")
368
  gr.Markdown(
369
  """
370
- 1. **Enter or Generate Text:** Type directly in the text box—or enter a character description and click “Generate Text” to auto-populate. Edit as needed.
371
- 2. **Synthesize Speech:** Click “Synthesize Speech” to generate two audio outputs.
372
- 3. **Listen & Compare:** Play back both audio options to hear the differences.
373
- 4. **Vote for Your Favorite:** Click “Vote for Option A” or “Vote for Option B” to cast your vote.
 
374
  """
375
  )
376
 
 
220
  if not option_map or vote_submitted:
221
  return gr.skip(), gr.skip(), gr.skip(), gr.skip()
222
 
223
+ option_a_selected = selected_button == constants.SELECT_OPTION_A
224
  selected_option, other_option = (
225
  (constants.OPTION_A, constants.OPTION_B)
226
  if option_a_selected
 
282
  return (
283
  gr.update(value=None),
284
  gr.update(value=None, autoplay=False),
285
+ gr.update(value=constants.SELECT_OPTION_A, variant="secondary"),
286
+ gr.update(value=constants.SELECT_OPTION_B, variant="secondary"),
287
  None,
288
  None,
289
  False,
 
299
  interactive=True,
300
  )
301
  character_description_input = gr.Textbox(
302
+ label="Character Description",
303
  placeholder="Enter a character description...",
304
  lines=3,
305
  max_lines=8,
306
  max_length=constants.CHARACTER_DESCRIPTION_MAX_LENGTH,
307
  show_copy_button=True,
308
  )
309
+ generate_text_button = gr.Button("Generate Text", variant="secondary")
310
  return (
311
  sample_character_description_dropdown,
312
  character_description_input,
 
317
  def build_output_section() -> (
318
  Tuple[gr.Textbox, gr.Button, gr.Audio, gr.Audio, gr.Button, gr.Button]
319
  ):
320
+ """Builds the output section including text input, audio players, and vote buttons."""
321
  text_input = gr.Textbox(
322
+ label="Input Text",
323
+ placeholder="Enter or generate text for synthesis...",
324
  interactive=True,
325
  autoscroll=False,
326
  lines=3,
 
328
  max_length=constants.CHARACTER_DESCRIPTION_MAX_LENGTH,
329
  show_copy_button=True,
330
  )
331
+ synthesize_speech_button = gr.Button("Synthesize Speech", variant="primary")
332
  with gr.Row(equal_height=True):
333
  option_a_audio_player = gr.Audio(
334
  label=constants.OPTION_A, type="filepath", interactive=False
 
337
  label=constants.OPTION_B, type="filepath", interactive=False
338
  )
339
  with gr.Row(equal_height=True):
340
+ vote_button_a = gr.Button(constants.SELECT_OPTION_A, interactive=False)
341
+ vote_button_b = gr.Button(constants.SELECT_OPTION_B, interactive=False)
342
  return (
343
  text_input,
344
  synthesize_speech_button,
 
367
  gr.Markdown("# Expressive TTS Arena")
368
  gr.Markdown(
369
  """
370
+ 1. **Choose or enter a character description**: Select a sample from the list or enter your own to guide text and voice generation.
371
+ 2. **Generate text**: Click **"Generate Text"** to create dialogue based on the character. The generated text will appear in the input field automatically—edit it if needed.
372
+ 3. **Synthesize speech**: Click **"Synthesize Speech"** to send your text and character description to two TTS APIs. Each API generates a voice and synthesizes speech in that voice.
373
+ 4. **Listen & compare**: Play both audio options and assess their expressiveness.
374
+ 5. **Vote for the best**: Click **"Select Option A"** or **"Select Option B"** to choose the most expressive output.
375
  """
376
  )
377
 
src/constants.py CHANGED
@@ -25,8 +25,8 @@ CHARACTER_DESCRIPTION_MAX_LENGTH: int = 800
25
  OPTION_A: OptionKey = "Option A"
26
  OPTION_B: OptionKey = "Option B"
27
  TROPHY_EMOJI: str = "🏆"
28
- VOTE_FOR_OPTION_A: str = "Vote for option A"
29
- VOTE_FOR_OPTION_B: str = "Vote for option B"
30
 
31
 
32
  # A collection of pre-defined character descriptions categorized by theme, used to provide users with
 
25
  OPTION_A: OptionKey = "Option A"
26
  OPTION_B: OptionKey = "Option B"
27
  TROPHY_EMOJI: str = "🏆"
28
+ SELECT_OPTION_A: str = "Select Option A"
29
+ SELECT_OPTION_B: str = "Select Option B"
30
 
31
 
32
  # A collection of pre-defined character descriptions categorized by theme, used to provide users with
src/utils.py CHANGED
@@ -3,11 +3,6 @@ utils.py
3
 
4
  This file contains utility functions that are shared across the project.
5
  These functions provide reusable logic to simplify code in other modules.
6
-
7
- Functions:
8
- - truncate_text: Truncates a string to a specified length with ellipses. (used for logging)
9
- - validate_env_var: Ensures the presence of a specific environment variable and retrieves its value.
10
- - validate_character_description_length: Ensures that a voice description does not exceed the specified minimum or maximum length.
11
  """
12
 
13
  # Standard Library Imports
 
3
 
4
  This file contains utility functions that are shared across the project.
5
  These functions provide reusable logic to simplify code in other modules.
 
 
 
 
 
6
  """
7
 
8
  # Standard Library Imports