Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ import torch
|
|
3 |
import torchaudio
|
4 |
from speechbrain.inference.enhancement import SpectralMaskEnhancement
|
5 |
from speechbrain.inference.separation import SepformerSeparation as separator
|
6 |
-
import torchaudio
|
7 |
|
8 |
# Load the enhancement model
|
9 |
model = separator.from_hparams(
|
@@ -14,10 +13,10 @@ model = separator.from_hparams(
|
|
14 |
# Define the enhancement function
|
15 |
def enhance_audio(noisy_audio):
|
16 |
# Load and add a batch dimension to the audio tensor
|
17 |
-
noisy =
|
18 |
|
19 |
# Enhance the audio
|
20 |
-
enhanced =
|
21 |
|
22 |
# Save enhanced audio to a temporary file
|
23 |
enhanced_path = "enhanced.wav"
|
@@ -34,5 +33,5 @@ interface = gr.Interface(
|
|
34 |
description="Upload a noisy audio file to enhance the quality. The enhanced audio can be downloaded after processing."
|
35 |
)
|
36 |
|
37 |
-
# Launch the Gradio app
|
38 |
-
interface.launch()
|
|
|
3 |
import torchaudio
|
4 |
from speechbrain.inference.enhancement import SpectralMaskEnhancement
|
5 |
from speechbrain.inference.separation import SepformerSeparation as separator
|
|
|
6 |
|
7 |
# Load the enhancement model
|
8 |
model = separator.from_hparams(
|
|
|
13 |
# Define the enhancement function
|
14 |
def enhance_audio(noisy_audio):
|
15 |
# Load and add a batch dimension to the audio tensor
|
16 |
+
noisy = model.load_audio(noisy_audio).unsqueeze(0)
|
17 |
|
18 |
# Enhance the audio
|
19 |
+
enhanced = model.enhance_batch(noisy, lengths=torch.tensor([1.0]))
|
20 |
|
21 |
# Save enhanced audio to a temporary file
|
22 |
enhanced_path = "enhanced.wav"
|
|
|
33 |
description="Upload a noisy audio file to enhance the quality. The enhanced audio can be downloaded after processing."
|
34 |
)
|
35 |
|
36 |
+
# Launch the Gradio app with public link enabled
|
37 |
+
interface.launch(share=True)
|