|
import gradio as gr |
|
import torch |
|
from sgmse.model import SGMSENoiseReducer |
|
import soundfile as sf |
|
|
|
|
|
model = SGMSENoiseReducer.from_pretrained("sp-uhh/speech-enhancement-sgmse") |
|
|
|
|
|
def enhance_speech(noisy_audio): |
|
|
|
noisy, sr = sf.read(noisy_audio) |
|
|
|
|
|
enhanced_audio = model.enhance(noisy, sr) |
|
|
|
|
|
output_file = "enhanced_output.wav" |
|
sf.write(output_file, enhanced_audio, sr) |
|
|
|
return output_file |
|
|
|
|
|
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." |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
interface.launch() |
|
|