forked from asteroid-team/asteroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
separate.py
29 lines (25 loc) · 898 Bytes
/
separate.py
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
import torch, torchaudio
import argparse
import os
from model import MultiDecoderDPRNN
os.makedirs("outputs", exist_ok=True)
parser = argparse.ArgumentParser()
parser.add_argument(
"--wav_file",
type=str,
default="",
help="Path to the wav file to run model inference on.",
)
args = parser.parse_args()
mixture, sample_rate = torchaudio.load(args.wav_file)
model = MultiDecoderDPRNN.from_pretrained("JunzheJosephZhu/MultiDecoderDPRNN").eval()
if torch.cuda.is_available():
model.cuda()
mixture = mixture.cuda()
sources_est = model.separate(mixture).cpu()
for i, source in enumerate(sources_est):
torchaudio.save(f"outputs/{i}.wav", source[None], sample_rate)
print(
"Thank you for using Multi-Decoder-DPRNN to separate your mixture files. \
Please support our work by citing our paper: http://www.isle.illinois.edu/speech_web_lg/pubs/2021/zhu2021multi.pdf"
)