File size: 890 Bytes
091b1e0
 
 
f6561a5
091b1e0
 
 
 
bd0a813
 
091b1e0
 
 
 
bd0a813
091b1e0
e2b0b28
091b1e0
f6561a5
 
 
 
 
 
 
 
 
 
 
091b1e0
f6561a5
 
 
091b1e0
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 uuid
import ffmpeg
import gradio as gr
from pathlib import Path
from denoisers.SpectralGating import SpectralGating


def denoising_transform(audio):
    src_path = "cache_wav/original/{}.wav".format(str(uuid.uuid4()))
    tgt_path = "cache_wav/denoised/{}.wav".format(str(uuid.uuid4()))
    (ffmpeg.input(audio)
            .output(src_path, acodec='pcm_s16le', ac=1, ar=22050)
            .run()
    )
    model.predict(audio, tgt_path)
    return tgt_path


demo = gr.Interface(
    fn=denoising_transform,
    inputs=gr.Audio(label="Source Audio", source="microphone", type='filepath'),
    outputs=gr.Audio(label="Target Audio", type='filepath'),
    examples=[
        ["testing/wavs/p232_071.wav"],
        ["testing/wavs/p232_284.wav"],
    ],
    title="Denoising",
    interpretation="default",
)

if __name__ == "__main__":
    model = SpectralGating()
    demo.launch()