|
import gradio as gr |
|
from speechbrain.pretrained import SepformerSeparation as separator |
|
import torchaudio |
|
|
|
|
|
model = separator.from_hparams(source="speechbrain/sepformer-dns4-16k-enhancement", savedir='pretrained_models/sepformer-dns4-16k-enhancement') |
|
|
|
def predict_song(audio_path): |
|
est_sources = model.separate_file(path=audio_path) |
|
torchaudio.save("enhanced_wham.wav", est_sources[:, :, 0].detach().cpu(), 16000) |
|
return "enhanced_wham.wav" |
|
|
|
|
|
|
|
title = "Denoise Audio Using Sepformer" |
|
description = "Using SepFormer model implemented with SpeechBrain" |
|
article = "Tham khao Hunggingface [speechbrain/sepformer-wsj02mixt](https://huggingface.co/speechbrain/sepformer-wsj02mix)." |
|
|
|
|
|
demo = gr.Interface(fn=predict_song, |
|
inputs=gr.Audio(type="filepath"), |
|
outputs=gr.File(file_count="multiple", file_types=[".wav"]), |
|
title=title, |
|
description=description, |
|
article=article) |
|
|
|
|
|
demo.launch() |