Spaces:
Runtime error
Runtime error
agorlanov
commited on
Commit
•
131ee98
1
Parent(s):
da7b5b9
denose_diar
Browse files- app.py +10 -8
- utils/denoise_pipeline.py +12 -0
- utils/diarization_pipeline.py +11 -7
app.py
CHANGED
@@ -4,20 +4,22 @@ from scipy.io.wavfile import write
|
|
4 |
from simple_diarizer.diarizer import Diarizer
|
5 |
from simple_diarizer.utils import (check_wav_16khz_mono, convert_wavfile)
|
6 |
|
|
|
7 |
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
os.makedirs("out", exist_ok=True)
|
11 |
-
write('test.wav', audio[0], audio[1])
|
12 |
-
os.system("python3 -m demucs.separate -n htdemucs --two-stems=vocals -d cpu test.wav -o out")
|
13 |
-
return "./out/htdemucs/test/vocals.wav", "./out/htdemucs/test/no_vocals.wav"
|
14 |
-
|
15 |
|
16 |
title = "audio_denoise and speakser diarization"
|
17 |
|
18 |
gr.Interface(
|
19 |
-
|
20 |
gr.Audio(type="numpy", label="Input"),
|
21 |
-
[
|
|
|
|
|
|
|
22 |
title=title,
|
23 |
).launch(enable_queue=True)
|
|
|
4 |
from simple_diarizer.diarizer import Diarizer
|
5 |
from simple_diarizer.utils import (check_wav_16khz_mono, convert_wavfile)
|
6 |
|
7 |
+
from utils.denoise_pipeline import denoise
|
8 |
|
9 |
+
def main_pipeline(audio):
|
10 |
+
denoised_audio=denoise(audio)
|
11 |
+
result=denoise(denoised_audio)
|
12 |
|
13 |
+
return result
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
title = "audio_denoise and speakser diarization"
|
16 |
|
17 |
gr.Interface(
|
18 |
+
main_pipeline,
|
19 |
gr.Audio(type="numpy", label="Input"),
|
20 |
+
[
|
21 |
+
gr.Audio(type="filepath", label="Vocal"),
|
22 |
+
# gr.Audio(type="filepath", label="No Vocals / Instrumental")
|
23 |
+
],
|
24 |
title=title,
|
25 |
).launch(enable_queue=True)
|
utils/denoise_pipeline.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import torch
|
3 |
+
from scipy.io.wavfile import write
|
4 |
+
|
5 |
+
|
6 |
+
def denoise(audio):
|
7 |
+
os.makedirs("out", exist_ok=True)
|
8 |
+
write('test.wav', audio[0], audio[1])
|
9 |
+
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
10 |
+
|
11 |
+
os.system(f"python3 -m demucs.separate -n htdemucs --two-stems=vocals -d {device} test.wav -o out")
|
12 |
+
return "./out/htdemucs/test/vocals.wav" # , "./out/htdemucs/test/no_vocals.wav"
|
utils/diarization_pipeline.py
CHANGED
@@ -4,8 +4,6 @@ from simple_diarizer.utils import (check_wav_16khz_mono, convert_wavfile)
|
|
4 |
import soundfile as sf
|
5 |
|
6 |
|
7 |
-
|
8 |
-
|
9 |
class DiarizationPipeline:
|
10 |
def __init__(self, mode='torch'):
|
11 |
super(DiarizationPipeline, self).__init__()
|
@@ -22,13 +20,19 @@ class DiarizationPipeline:
|
|
22 |
|
23 |
# signal, fs = sf.read(wav_file)
|
24 |
#
|
25 |
-
segments = self.diar.diarize(wav_file,
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
30 |
|
31 |
|
32 |
if __name__ == '__main__':
|
33 |
-
pipeline = DiarizationPipeline('torch')
|
34 |
pipeline('path_audio')
|
|
|
4 |
import soundfile as sf
|
5 |
|
6 |
|
|
|
|
|
7 |
class DiarizationPipeline:
|
8 |
def __init__(self, mode='torch'):
|
9 |
super(DiarizationPipeline, self).__init__()
|
|
|
20 |
|
21 |
# signal, fs = sf.read(wav_file)
|
22 |
#
|
23 |
+
# segments = self.diar.diarize(wav_file,
|
24 |
+
# num_speakers=None,
|
25 |
+
# threshold=9e-1, )
|
26 |
+
|
27 |
+
return wav_file
|
28 |
+
|
29 |
+
|
30 |
+
pipeline = DiarizationPipeline('torch')
|
31 |
+
|
32 |
+
def run_diarization(audio):
|
33 |
|
34 |
+
return pipeline(audio)
|
35 |
|
36 |
|
37 |
if __name__ == '__main__':
|
|
|
38 |
pipeline('path_audio')
|