Spaces:
Running
Running
File size: 884 Bytes
2786fbb 9ba2a1c a67942c 9ba2a1c 27faa92 9ba2a1c a67942c 2786fbb 51499e8 a67942c 9ba2a1c 2786fbb 6dd1808 2786fbb 9ba2a1c 2786fbb c7104a2 0a35b67 68d3cae 9ba2a1c 2786fbb 9ba2a1c 2786fbb 7487639 9ba2a1c |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import torch
import gradio as gr
import yt_dlp as youtube_dl
from transformers import pipeline
from transformers.pipelines.audio_utils import ffmpeg_read
from speechbrain.pretrained import SepformerSeparation as separator
import torchaudio
import tempfile
import os
model = separator.from_hparams(source="speechbrain/sepformer-libri2mix", savedir='pretrained_models/sepformer-libri2mix')
demo = gr.Blocks()
def separateaudio(filepath):
est_sources = model.separate_file(path=filepath)
output_path = "file.wav"
torchaudio.save(output_path, est_sources[:, :, 0].detach().cpu(), 8000)
return output_path
separation = gr.Interface(
fn=separateaudio,
inputs=gr.Audio( type="filepath"),
outputs=gr.Audio(type="filepath"),
)
with demo:
gr.TabbedInterface(
[separation],
["Separate audio file"],
)
demo.launch()
|