Spaces:
Runtime error
Runtime error
Add examples folder
Browse files
app.py
CHANGED
|
@@ -442,31 +442,40 @@ def build_app():
|
|
| 442 |
step=0.01,
|
| 443 |
)
|
| 444 |
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
|
| 450 |
-
|
| 451 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
)
|
| 453 |
-
|
| 454 |
-
label="Reference
|
| 455 |
-
|
|
|
|
|
|
|
| 456 |
)
|
| 457 |
-
with gr.Row():
|
| 458 |
-
if_auto_label = gr.Checkbox(
|
| 459 |
-
label="Auto Labeling",
|
| 460 |
-
min_width=100,
|
| 461 |
-
scale=0,
|
| 462 |
-
value=False,
|
| 463 |
-
)
|
| 464 |
-
reference_text = gr.Textbox(
|
| 465 |
-
label="Reference Text",
|
| 466 |
-
lines=1,
|
| 467 |
-
placeholder="在一无所知中,梦里的一天结束了,一个新的「轮回」便会开始。",
|
| 468 |
-
value="",
|
| 469 |
-
)
|
| 470 |
with gr.Tab(label="Batch Inference"):
|
| 471 |
batch_infer_num = gr.Slider(
|
| 472 |
label="Batch infer nums",
|
|
@@ -536,7 +545,28 @@ def build_app():
|
|
| 536 |
],
|
| 537 |
outputs=[reference_text],
|
| 538 |
)
|
| 539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
# # Submit
|
| 541 |
generate.click(
|
| 542 |
inference_wrapper,
|
|
|
|
| 442 |
step=0.01,
|
| 443 |
)
|
| 444 |
|
| 445 |
+
with gr.Tab(label="Reference Audio"):
|
| 446 |
+
gr.Markdown(
|
| 447 |
+
"5 to 10 seconds of reference audio, useful for specifying speaker."
|
| 448 |
+
)
|
| 449 |
|
| 450 |
+
enable_reference_audio = gr.Checkbox(
|
| 451 |
+
label="Enable Reference Audio",
|
| 452 |
+
)
|
| 453 |
+
|
| 454 |
+
# Add dropdown for selecting example audio files
|
| 455 |
+
example_audio_files = [f for f in os.listdir("examples") if f.endswith(".wav")]
|
| 456 |
+
example_audio_dropdown = gr.Dropdown(
|
| 457 |
+
label="Select Example Audio",
|
| 458 |
+
choices=[""] + example_audio_files,
|
| 459 |
+
value=""
|
| 460 |
+
)
|
| 461 |
+
|
| 462 |
+
reference_audio = gr.Audio(
|
| 463 |
+
label="Reference Audio",
|
| 464 |
+
type="filepath",
|
| 465 |
+
)
|
| 466 |
+
with gr.Row():
|
| 467 |
+
if_auto_label = gr.Checkbox(
|
| 468 |
+
label="Auto Labeling",
|
| 469 |
+
min_width=100,
|
| 470 |
+
scale=0,
|
| 471 |
+
value=False,
|
| 472 |
)
|
| 473 |
+
reference_text = gr.Textbox(
|
| 474 |
+
label="Reference Text",
|
| 475 |
+
lines=1,
|
| 476 |
+
placeholder="在一无所知中,梦里的一天结束了,一个新的「轮回」便会开始。",
|
| 477 |
+
value="",
|
| 478 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
with gr.Tab(label="Batch Inference"):
|
| 480 |
batch_infer_num = gr.Slider(
|
| 481 |
label="Batch infer nums",
|
|
|
|
| 545 |
],
|
| 546 |
outputs=[reference_text],
|
| 547 |
)
|
| 548 |
+
|
| 549 |
+
def select_example_audio(audio_file):
|
| 550 |
+
if audio_file:
|
| 551 |
+
audio_path = os.path.join("examples", audio_file)
|
| 552 |
+
lab_file = os.path.splitext(audio_file)[0] + ".lab"
|
| 553 |
+
lab_path = os.path.join("examples", lab_file)
|
| 554 |
+
|
| 555 |
+
if os.path.exists(lab_path):
|
| 556 |
+
with open(lab_path, "r", encoding="utf-8") as f:
|
| 557 |
+
lab_content = f.read().strip()
|
| 558 |
+
else:
|
| 559 |
+
lab_content = ""
|
| 560 |
+
|
| 561 |
+
return audio_path, lab_content, True
|
| 562 |
+
return None, "", False
|
| 563 |
+
|
| 564 |
+
# Connect the dropdown to update reference audio and text
|
| 565 |
+
example_audio_dropdown.change(
|
| 566 |
+
fn=select_example_audio,
|
| 567 |
+
inputs=[example_audio_dropdown],
|
| 568 |
+
outputs=[reference_audio, reference_text, enable_reference_audio]
|
| 569 |
+
)
|
| 570 |
# # Submit
|
| 571 |
generate.click(
|
| 572 |
inference_wrapper,
|