urusha / app.py
Shokoufehhh's picture
Update app.py
c65e0e9 verified
raw
history blame
1.02 kB
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()