Spaces:
Running
Running
zach
commited on
Commit
·
7f21bab
1
Parent(s):
ee8b196
Improves UI content for clarity
Browse files- src/app.py +16 -15
- src/constants.py +2 -2
- 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.
|
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.
|
286 |
-
gr.update(value=constants.
|
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
|
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
|
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
|
321 |
text_input = gr.Textbox(
|
322 |
-
label="Text",
|
323 |
-
placeholder="
|
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
|
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.
|
341 |
-
vote_button_b = gr.Button(constants.
|
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. **
|
371 |
-
2. **
|
372 |
-
3. **
|
373 |
-
4. **
|
|
|
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 |
-
|
29 |
-
|
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
|