Update app.py
Browse files
app.py
CHANGED
@@ -353,10 +353,10 @@ class AudioUpscaler:
|
|
353 |
print(f"File created: {output_file}")
|
354 |
|
355 |
# Cleanup
|
356 |
-
del waveform
|
357 |
gc.collect()
|
358 |
torch.cuda.empty_cache()
|
359 |
-
return
|
|
|
360 |
|
361 |
|
362 |
|
@@ -386,7 +386,7 @@ def inference(audio_file, model_name, guidance_scale, ddim_steps, seed):
|
|
386 |
|
387 |
return (48000, waveform)
|
388 |
|
389 |
-
|
390 |
def upscale_audio(
|
391 |
input_file,
|
392 |
output_folder,
|
@@ -415,10 +415,13 @@ def upscale_audio(
|
|
415 |
Returns:
|
416 |
tuple: Upscaled audio data and sample rate.
|
417 |
"""
|
|
|
|
|
|
|
|
|
418 |
upscaler = AudioUpscaler()
|
419 |
upscaler.setup()
|
420 |
-
|
421 |
-
output_file = upscaler.predict(
|
422 |
input_file,
|
423 |
output_folder,
|
424 |
ddim_steps=ddim_steps,
|
@@ -435,7 +438,7 @@ def upscale_audio(
|
|
435 |
|
436 |
gc.collect()
|
437 |
|
438 |
-
return
|
439 |
|
440 |
os.getcwd()
|
441 |
gr.Textbox
|
@@ -453,18 +456,6 @@ iface = gr.Interface(
|
|
453 |
gr.Checkbox(label="Multiband Ensemble", value=False, info="Enhance high frequencies"),
|
454 |
gr.Slider(500, 15000, value=9000, step=500, label="Crossover Frequency (Hz)", info="For multiband processing", visible=True)
|
455 |
],
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
iface = gr.Interface(
|
460 |
-
fn=inference,
|
461 |
-
inputs=[
|
462 |
-
gr.Audio(type="filepath", label="Input Audio"),
|
463 |
-
gr.Dropdown(["basic", "speech"], value="basic", label="Model"),
|
464 |
-
gr.Slider(1, 10, value=3.5, step=0.1, label="Guidance Scale", info="Guidance scale (Large => better quality and relavancy to text; Small => better diversity)"),
|
465 |
-
gr.Slider(1, 100, value=50, step=1, label="DDIM Steps", info="The sampling step for DDIM"),
|
466 |
-
gr.Number(value=42, precision=0, label="Seed", info="Changing this value (any integer number) will lead to a different generation result, put 0 for a random one.")
|
467 |
-
],
|
468 |
outputs=gr.Audio(type="numpy", label="Output Audio"),
|
469 |
title="AudioSR",
|
470 |
description="Audio Super Resolution with AudioSR"
|
|
|
353 |
print(f"File created: {output_file}")
|
354 |
|
355 |
# Cleanup
|
|
|
356 |
gc.collect()
|
357 |
torch.cuda.empty_cache()
|
358 |
+
return waveform
|
359 |
+
# return output_file
|
360 |
|
361 |
|
362 |
|
|
|
386 |
|
387 |
return (48000, waveform)
|
388 |
|
389 |
+
@spaces.GPU
|
390 |
def upscale_audio(
|
391 |
input_file,
|
392 |
output_folder,
|
|
|
415 |
Returns:
|
416 |
tuple: Upscaled audio data and sample rate.
|
417 |
"""
|
418 |
+
if torch.cuda.is_avaible():
|
419 |
+
torch.cuda.empty_cache()
|
420 |
+
|
421 |
+
gc.collect()
|
422 |
upscaler = AudioUpscaler()
|
423 |
upscaler.setup()
|
424 |
+
waveform = upscaler.predict(
|
|
|
425 |
input_file,
|
426 |
output_folder,
|
427 |
ddim_steps=ddim_steps,
|
|
|
438 |
|
439 |
gc.collect()
|
440 |
|
441 |
+
return waveform
|
442 |
|
443 |
os.getcwd()
|
444 |
gr.Textbox
|
|
|
456 |
gr.Checkbox(label="Multiband Ensemble", value=False, info="Enhance high frequencies"),
|
457 |
gr.Slider(500, 15000, value=9000, step=500, label="Crossover Frequency (Hz)", info="For multiband processing", visible=True)
|
458 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
outputs=gr.Audio(type="numpy", label="Output Audio"),
|
460 |
title="AudioSR",
|
461 |
description="Audio Super Resolution with AudioSR"
|