demomodels commited on
Commit
0c16d63
1 Parent(s): acbc440

Added audio separation

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -4,6 +4,20 @@ import json
4
  import numpy as np
5
  from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
8
  torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
9
 
 
4
  import numpy as np
5
  from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
6
 
7
+ # This code was omitted for deployment reasons (model is too RAM-hungry)
8
+
9
+ # from speechbrain.inference.separation import SepformerSeparation as separator
10
+ # import torchaudio
11
+
12
+ # model = separator.from_hparams(source="speechbrain/sepformer-whamr16k", savedir='pretrained_models/sepformer-whamr16k')
13
+
14
+ # def separate_speech(path):
15
+ # est_sources = model.separate_file(path=path)
16
+ # output_path = "output.wav"
17
+ # torchaudio.save(output_path, est_sources[:, :, 0].detach().cpu(), 16000)
18
+ # return output_path
19
+
20
+
21
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
22
  torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
23