Spaces:
Running
on
A10G
Running
on
A10G
lengyue233
commited on
Commit
•
9bd8a0b
1
Parent(s):
2dc5ce9
Update app.py
Browse files
app.py
CHANGED
@@ -232,56 +232,6 @@ global_audio_list = []
|
|
232 |
global_error_list = []
|
233 |
|
234 |
|
235 |
-
def inference_wrapper(
|
236 |
-
text,
|
237 |
-
enable_reference_audio,
|
238 |
-
reference_audio,
|
239 |
-
reference_text,
|
240 |
-
max_new_tokens,
|
241 |
-
chunk_length,
|
242 |
-
top_p,
|
243 |
-
repetition_penalty,
|
244 |
-
temperature,
|
245 |
-
seed,
|
246 |
-
batch_infer_num,
|
247 |
-
):
|
248 |
-
audios = []
|
249 |
-
errors = []
|
250 |
-
|
251 |
-
for _ in range(batch_infer_num):
|
252 |
-
result = inference(
|
253 |
-
text,
|
254 |
-
enable_reference_audio,
|
255 |
-
reference_audio,
|
256 |
-
reference_text,
|
257 |
-
max_new_tokens,
|
258 |
-
chunk_length,
|
259 |
-
top_p,
|
260 |
-
repetition_penalty,
|
261 |
-
temperature,
|
262 |
-
seed,
|
263 |
-
)
|
264 |
-
|
265 |
-
_, audio_data, error_message = next(result)
|
266 |
-
|
267 |
-
audios.append(
|
268 |
-
gr.Audio(value=audio_data if audio_data else None, visible=True),
|
269 |
-
)
|
270 |
-
errors.append(
|
271 |
-
gr.HTML(value=error_message if error_message else None, visible=True),
|
272 |
-
)
|
273 |
-
|
274 |
-
for _ in range(batch_infer_num, n_audios):
|
275 |
-
audios.append(
|
276 |
-
gr.Audio(value=None, visible=False),
|
277 |
-
)
|
278 |
-
errors.append(
|
279 |
-
gr.HTML(value=None, visible=False),
|
280 |
-
)
|
281 |
-
|
282 |
-
return None, *audios, *errors
|
283 |
-
|
284 |
-
|
285 |
def wav_chunk_header(sample_rate=44100, bit_depth=16, channels=1):
|
286 |
buffer = io.BytesIO()
|
287 |
|
@@ -394,17 +344,14 @@ def build_app():
|
|
394 |
)
|
395 |
)
|
396 |
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
choices=[""] + example_audio_files,
|
406 |
-
value=""
|
407 |
-
)
|
408 |
|
409 |
with gr.Row():
|
410 |
use_memory_cache = gr.Radio(
|
@@ -418,6 +365,7 @@ def build_app():
|
|
418 |
label=i18n("Reference Audio"),
|
419 |
type="filepath",
|
420 |
)
|
|
|
421 |
with gr.Row():
|
422 |
reference_text = gr.Textbox(
|
423 |
label=i18n("Reference Text"),
|
@@ -506,14 +454,14 @@ def build_app():
|
|
506 |
else:
|
507 |
lab_content = ""
|
508 |
|
509 |
-
return audio_path, lab_content
|
510 |
-
return None, ""
|
511 |
|
512 |
# Connect the dropdown to update reference audio and text
|
513 |
example_audio_dropdown.change(
|
514 |
fn=select_example_audio,
|
515 |
inputs=[example_audio_dropdown],
|
516 |
-
outputs=[reference_audio, reference_text
|
517 |
)
|
518 |
|
519 |
# Submit
|
@@ -521,7 +469,7 @@ def build_app():
|
|
521 |
inference_wrapper,
|
522 |
[
|
523 |
refined_text,
|
524 |
-
|
525 |
reference_audio,
|
526 |
reference_text,
|
527 |
max_new_tokens,
|
|
|
232 |
global_error_list = []
|
233 |
|
234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
def wav_chunk_header(sample_rate=44100, bit_depth=16, channels=1):
|
236 |
buffer = io.BytesIO()
|
237 |
|
|
|
344 |
)
|
345 |
)
|
346 |
|
347 |
+
with gr.Row():
|
348 |
+
# Add dropdown for selecting example audio files
|
349 |
+
example_audio_files = [f for f in os.listdir("examples") if f.endswith(".wav")]
|
350 |
+
example_audio_dropdown = gr.Dropdown(
|
351 |
+
label="Select Example Audio",
|
352 |
+
choices=[""] + example_audio_files,
|
353 |
+
value=""
|
354 |
+
)
|
|
|
|
|
|
|
355 |
|
356 |
with gr.Row():
|
357 |
use_memory_cache = gr.Radio(
|
|
|
365 |
label=i18n("Reference Audio"),
|
366 |
type="filepath",
|
367 |
)
|
368 |
+
|
369 |
with gr.Row():
|
370 |
reference_text = gr.Textbox(
|
371 |
label=i18n("Reference Text"),
|
|
|
454 |
else:
|
455 |
lab_content = ""
|
456 |
|
457 |
+
return audio_path, lab_content
|
458 |
+
return None, ""
|
459 |
|
460 |
# Connect the dropdown to update reference audio and text
|
461 |
example_audio_dropdown.change(
|
462 |
fn=select_example_audio,
|
463 |
inputs=[example_audio_dropdown],
|
464 |
+
outputs=[reference_audio, reference_text]
|
465 |
)
|
466 |
|
467 |
# Submit
|
|
|
469 |
inference_wrapper,
|
470 |
[
|
471 |
refined_text,
|
472 |
+
normalize,
|
473 |
reference_audio,
|
474 |
reference_text,
|
475 |
max_new_tokens,
|