File size: 1,019 Bytes
ee164b6
c65e0e9
 
 
ee164b6
c65e0e9
 
ee164b6
c65e0e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
import torch
from sgmse.model import SGMSENoiseReducer  # Adjust import as per your model structure
import soundfile as sf

# Load your pre-trained model
model = SGMSENoiseReducer.from_pretrained("sp-uhh/speech-enhancement-sgmse")

# Define a function to process the uploaded file
def enhance_speech(noisy_audio):
    # Load noisy audio file
    noisy, sr = sf.read(noisy_audio)

    # Apply your model to enhance the speech
    enhanced_audio = model.enhance(noisy, sr)

    # Save enhanced audio to a temporary file
    output_file = "enhanced_output.wav"
    sf.write(output_file, enhanced_audio, sr)

    return output_file

# Set up the Gradio interface
interface = gr.Interface(
    fn=enhance_speech,
    inputs=gr.Audio(source="upload", type="filepath"),
    outputs=gr.Audio(type="file"),
    title="SGMSE Speech Enhancement",
    description="Upload a noisy audio file and download the enhanced (clean) version."
)

# Launch the interface
if __name__ == "__main__":
    interface.launch()