agorlanov commited on
Commit
9872c27
1 Parent(s): c39b8bf

fix_denose_diar

Browse files
main_pipeline.py CHANGED
@@ -1,4 +1,5 @@
1
  import librosa
 
2
 
3
  from utils.denoise_pipeline import denoise
4
  from utils.diarization_pipeline import diarization
@@ -32,11 +33,11 @@ def save_speaker_audios(segments, denoised_audio_path, out_folder='out', out_f=4
32
 
33
 
34
  def main_pipeline(audio_path):
35
- denoised_audio_path = denoise(audio_path)
36
- # denoised_audio_path = audio_path
 
37
  segments = diarization(denoised_audio_path)
38
  result_diarization = save_speaker_audios(segments, denoised_audio_path)
39
- # return [denoised_audio_path] + result
40
  return denoised_audio_path, result_diarization
41
 
42
 
 
1
  import librosa
2
+ import torch
3
 
4
  from utils.denoise_pipeline import denoise
5
  from utils.diarization_pipeline import diarization
 
33
 
34
 
35
  def main_pipeline(audio_path):
36
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
37
+
38
+ denoised_audio_path = denoise(audio_path, device)
39
  segments = diarization(denoised_audio_path)
40
  result_diarization = save_speaker_audios(segments, denoised_audio_path)
 
41
  return denoised_audio_path, result_diarization
42
 
43
 
requirements.txt CHANGED
@@ -19,4 +19,5 @@ lightning_fabric
19
  modelscope
20
  rotary_embedding_torch
21
  simple-diarizer
22
- soundfile
 
 
19
  modelscope
20
  rotary_embedding_torch
21
  simple-diarizer
22
+ soundfile
23
+ librosa
utils/denoise_pipeline.py CHANGED
@@ -23,8 +23,8 @@ def denoise(filename, device):
23
  vocal_wav = vocal_wav.numpy()
24
  vocal_wav = librosa.to_mono(vocal_wav)
25
  vocal_wav = vocal_wav.T
26
- # vocal_wav = librosa.resample(vocal_wav, orig_sr=sr, target_sr=out_f)
27
- write('denoise.wav', 44100, vocal_wav)
28
 
29
  return 'denoise.wav'
30
 
 
23
  vocal_wav = vocal_wav.numpy()
24
  vocal_wav = librosa.to_mono(vocal_wav)
25
  vocal_wav = vocal_wav.T
26
+ vocal_wav = librosa.resample(vocal_wav, orig_sr=44100, target_sr=48000)
27
+ write('denoise.wav', 48000, vocal_wav)
28
 
29
  return 'denoise.wav'
30
 
utils/diarization_pipeline.py CHANGED
@@ -6,7 +6,7 @@ import soundfile as sf
6
 
7
 
8
  class DiarizationPipeline:
9
- def __init__(self, mode='torch'):
10
  super(DiarizationPipeline, self).__init__()
11
  self.diar = Diarizer(
12
  embed_model='ecapa', # supported types: ['xvec', 'ecapa']
@@ -26,7 +26,7 @@ class DiarizationPipeline:
26
  return segments
27
 
28
 
29
- diarization = DiarizationPipeline('torch')
30
 
31
  if __name__ == '__main__':
32
  diarization('../out.wav')
 
6
 
7
 
8
  class DiarizationPipeline:
9
+ def __init__(self, ):
10
  super(DiarizationPipeline, self).__init__()
11
  self.diar = Diarizer(
12
  embed_model='ecapa', # supported types: ['xvec', 'ecapa']
 
26
  return segments
27
 
28
 
29
+ diarization = DiarizationPipeline()
30
 
31
  if __name__ == '__main__':
32
  diarization('../out.wav')