Spaces:
Running
Running
fx
Browse files
app.py
CHANGED
@@ -464,6 +464,10 @@ def other_tts(text='Hallov worlds Far over the',
|
|
464 |
return tmp_file
|
465 |
|
466 |
|
|
|
|
|
|
|
|
|
467 |
description = (
|
468 |
"Estimate **age**, **gender**, and **expression** "
|
469 |
"of the speaker contained in an audio file or microphone recording. \n"
|
@@ -473,11 +477,7 @@ description = (
|
|
473 |
f"whereas [{expression_model_name}]"
|
474 |
f"(https://huggingface.co/{expression_model_name}) "
|
475 |
"recognises the expression dimensions arousal, dominance, and valence. "
|
476 |
-
|
477 |
-
|
478 |
-
def update_selected_voice(voice_filename, current_text):
|
479 |
-
_full = 'wav/' + voice_filename + '.wav'
|
480 |
-
return _full, gr.Textbox.update(label=f"Text for TTS: Vox=`{voice_filename}`", value=current_text)
|
481 |
|
482 |
css_buttons = """
|
483 |
.cool-button {
|
@@ -504,30 +504,49 @@ css_buttons = """
|
|
504 |
|
505 |
with gr.Blocks(theme='huggingface', css=css_buttons) as demo:
|
506 |
with gr.Tab(label="other TTS"):
|
507 |
-
|
508 |
-
selected_voice = gr.State(value=
|
|
|
509 |
with gr.Row():
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
output_audio = gr.Audio(label="TTS Output")
|
|
|
517 |
with gr.Column():
|
518 |
voice_buttons = []
|
519 |
for i in range(0, len(VOICES), 7):
|
520 |
with gr.Row(elem_classes=["cool-row"]):
|
521 |
for voice_filename in VOICES[i:i+7]:
|
522 |
voice_filename = voice_filename[4:-4] # drop wav/ for visibility
|
523 |
-
button = gr.Button(voice_filename,
|
524 |
-
|
525 |
-
|
526 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
527 |
voice_buttons.append(button)
|
528 |
-
|
529 |
-
|
530 |
-
|
|
|
|
|
|
|
531 |
|
532 |
with gr.Tab(label="Speech Analysis"):
|
533 |
with gr.Row():
|
@@ -560,4 +579,4 @@ with gr.Blocks(theme='huggingface', css=css_buttons) as demo:
|
|
560 |
submit_btn.click(recognize, input, outputs)
|
561 |
|
562 |
|
563 |
-
demo.launch(debug=True)
|
|
|
464 |
return tmp_file
|
465 |
|
466 |
|
467 |
+
def update_selected_voice(voice_filename):
|
468 |
+
return 'wav/' + voice_filename + '.wav'
|
469 |
+
|
470 |
+
|
471 |
description = (
|
472 |
"Estimate **age**, **gender**, and **expression** "
|
473 |
"of the speaker contained in an audio file or microphone recording. \n"
|
|
|
477 |
f"whereas [{expression_model_name}]"
|
478 |
f"(https://huggingface.co/{expression_model_name}) "
|
479 |
"recognises the expression dimensions arousal, dominance, and valence. "
|
480 |
+
)
|
|
|
|
|
|
|
|
|
481 |
|
482 |
css_buttons = """
|
483 |
.cool-button {
|
|
|
504 |
|
505 |
with gr.Blocks(theme='huggingface', css=css_buttons) as demo:
|
506 |
with gr.Tab(label="other TTS"):
|
507 |
+
|
508 |
+
selected_voice = gr.State(value='wav/en_US_m-ailabs_mary_ann.wav')
|
509 |
+
|
510 |
with gr.Row():
|
511 |
+
voice_info = gr.Markdown(f'`{selected_voice.value}`')
|
512 |
+
|
513 |
+
# Main input and output components
|
514 |
+
with gr.Row():
|
515 |
+
text_input = gr.Textbox(
|
516 |
+
label="Enter text for TTS:",
|
517 |
+
placeholder="Type your message here...",
|
518 |
+
lines=4,
|
519 |
+
value="Farover the misty mountains cold too dungeons deep and caverns old.",
|
520 |
+
)
|
521 |
+
generate_button = gr.Button("Generate Audio", variant="primary")
|
522 |
+
|
523 |
output_audio = gr.Audio(label="TTS Output")
|
524 |
+
|
525 |
with gr.Column():
|
526 |
voice_buttons = []
|
527 |
for i in range(0, len(VOICES), 7):
|
528 |
with gr.Row(elem_classes=["cool-row"]):
|
529 |
for voice_filename in VOICES[i:i+7]:
|
530 |
voice_filename = voice_filename[4:-4] # drop wav/ for visibility
|
531 |
+
button = gr.Button(voice_filename, elem_classes=["cool-button"])
|
532 |
+
|
533 |
+
button.click(
|
534 |
+
fn=update_selected_voice,
|
535 |
+
inputs=[gr.Textbox(value=voice_filename, visible=False)],
|
536 |
+
outputs=[selected_voice]
|
537 |
+
)
|
538 |
+
button.click(
|
539 |
+
fn=lambda v=voice_filename: f'`{v}`',
|
540 |
+
inputs=None,
|
541 |
+
outputs=voice_info
|
542 |
+
)
|
543 |
voice_buttons.append(button)
|
544 |
+
|
545 |
+
generate_button.click(
|
546 |
+
fn=other_tts,
|
547 |
+
inputs=[text_input, selected_voice],
|
548 |
+
outputs=output_audio
|
549 |
+
)
|
550 |
|
551 |
with gr.Tab(label="Speech Analysis"):
|
552 |
with gr.Row():
|
|
|
579 |
submit_btn.click(recognize, input, outputs)
|
580 |
|
581 |
|
582 |
+
demo.launch(debug=True)
|