File size: 1,780 Bytes
b1fdcc2
b0a9f8f
b1fdcc2
 
 
b0a9f8f
b1fdcc2
 
 
 
 
 
 
 
 
 
 
 
4c92361
b1fdcc2
4c92361
b0a9f8f
4c92361
b1fdcc2
4c92361
 
 
 
 
 
 
 
b0a9f8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c92361
 
 
 
 
 
 
 
b1fdcc2
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import argparse
from pathlib import Path

import warnings
from app.service.vocal_remover.runner import load_model, separate
from app.service.demucs_runner import separator

warnings.simplefilter("ignore", UserWarning)
warnings.simplefilter("ignore", FutureWarning)
warnings.filterwarnings("ignore", module="streamlit")


def main():
    p = argparse.ArgumentParser()
    p.add_argument("--gpu", "-g", type=int, default=-1)
    p.add_argument("--pretrained_model", "-P", type=str, default="baseline.pth")
    p.add_argument("--input", "-i", required=True)
    p.add_argument("--output_dir", "-o", type=str, default="")
    p.add_argument("--full_mode", "-n", default=False)
    args = p.parse_args()
    print(args)
    input_file = args.input
    full_mode = bool(args.full_mode)
    model, device = load_model(pretrained_model=args.pretrained_model)

    if full_mode:
        separate(
            input=input_file,
            model=model,
            device=device,
            output_dir=args.output_dir,
        )
        for stem, model_name in [("vocals", "htdemucs"), (None, "htdemucs"), (None, "htdemucs_6s")]:
            separator(
                tracks=[Path(input_file)],
                out=Path(args.output_dir),
                model=model_name,
                shifts=1,
                overlap=0.5,
                stem=stem,
                int24=False,
                float32=False,
                clip_mode="rescale",
                mp3=True,
                mp3_bitrate=320,
                verbose=False,
            )
    else:
        separate(
            input=input_file,
            model=model,
            device=device,
            output_dir=args.output_dir,
            only_no_vocals=True,
        )


if __name__ == "__main__":
    main()