Spaces:
Running
Running
zach
commited on
Commit
·
f64ebd7
1
Parent(s):
b41805f
Improve clarity of instructions, minor adjustment to UI component layout
Browse files- src/app.py +38 -41
src/app.py
CHANGED
@@ -208,29 +208,27 @@ def reset_ui() -> Tuple[gr.update, gr.update, gr.update, gr.update, None, None,
|
|
208 |
|
209 |
def build_input_section() -> Tuple[gr.Markdown, gr.Dropdown, gr.Textbox, gr.Button]:
|
210 |
""" Builds the input section including instructions, sample prompt dropdown, prompt input, and generate button """
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
)
|
233 |
-
generate_text_button = gr.Button('Generate text', variant='secondary')
|
234 |
return (
|
235 |
instructions,
|
236 |
sample_prompt_dropdown,
|
@@ -241,24 +239,23 @@ def build_input_section() -> Tuple[gr.Markdown, gr.Dropdown, gr.Textbox, gr.Butt
|
|
241 |
|
242 |
def build_output_section() -> Tuple[gr.Textbox, gr.Button, gr.Audio, gr.Audio, gr.Button, gr.Button]:
|
243 |
""" Builds the output section including generated text, audio players, and vote buttons. """
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
vote_button_b = gr.Button(VOTE_FOR_OPTION_B, interactive=False)
|
262 |
return (
|
263 |
text_input,
|
264 |
synthesize_speech_button,
|
|
|
208 |
|
209 |
def build_input_section() -> Tuple[gr.Markdown, gr.Dropdown, gr.Textbox, gr.Button]:
|
210 |
""" Builds the input section including instructions, sample prompt dropdown, prompt input, and generate button """
|
211 |
+
instructions = gr.Markdown("""
|
212 |
+
1. **Enter or Generate Text:** Type directly in the Text box, or optionally enter a Prompt, click "Generate text", and edit if needed.
|
213 |
+
2. **Synthesize Speech:** Click "Synthesize speech" to generate two audio outputs.
|
214 |
+
3. **Listen & Compare:** Playback both options (A & B) to hear the differences.
|
215 |
+
4. **Vote for Your Favorite:** Click "Vote for option A" or "Vote for option B" to choose the best one.
|
216 |
+
""")
|
217 |
+
sample_prompt_dropdown = gr.Dropdown(
|
218 |
+
choices=list(SAMPLE_PROMPTS.keys()),
|
219 |
+
label='Choose a sample prompt (or enter your own)',
|
220 |
+
value=None,
|
221 |
+
interactive=True,
|
222 |
+
)
|
223 |
+
prompt_input = gr.Textbox(
|
224 |
+
label='Prompt',
|
225 |
+
placeholder='Enter your prompt...',
|
226 |
+
lines=2,
|
227 |
+
max_lines=2,
|
228 |
+
max_length=PROMPT_MAX_LENGTH,
|
229 |
+
show_copy_button=True,
|
230 |
+
)
|
231 |
+
generate_text_button = gr.Button('Generate text', variant='secondary')
|
|
|
|
|
232 |
return (
|
233 |
instructions,
|
234 |
sample_prompt_dropdown,
|
|
|
239 |
|
240 |
def build_output_section() -> Tuple[gr.Textbox, gr.Button, gr.Audio, gr.Audio, gr.Button, gr.Button]:
|
241 |
""" Builds the output section including generated text, audio players, and vote buttons. """
|
242 |
+
text_input = gr.Textbox(
|
243 |
+
label='Text',
|
244 |
+
placeholder='Enter text to synthesize speech...',
|
245 |
+
interactive=True,
|
246 |
+
autoscroll=False,
|
247 |
+
lines=4,
|
248 |
+
max_lines=12,
|
249 |
+
max_length=PROMPT_MAX_LENGTH,
|
250 |
+
show_copy_button=True,
|
251 |
+
)
|
252 |
+
synthesize_speech_button = gr.Button('Synthesize speech', variant='primary')
|
253 |
+
with gr.Row(equal_height=True):
|
254 |
+
option_a_audio_player = gr.Audio(label=OPTION_A, type='filepath', interactive=False)
|
255 |
+
option_b_audio_player = gr.Audio(label=OPTION_B, type='filepath', interactive=False)
|
256 |
+
with gr.Row(equal_height=True):
|
257 |
+
vote_button_a = gr.Button(VOTE_FOR_OPTION_A, interactive=False)
|
258 |
+
vote_button_b = gr.Button(VOTE_FOR_OPTION_B, interactive=False)
|
|
|
259 |
return (
|
260 |
text_input,
|
261 |
synthesize_speech_button,
|