File size: 777 Bytes
f5799e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Separate vocals from audio"""

import subprocess

from modules.console_colors import (
    ULTRASINGER_HEAD,
    blue_highlighted,
    red_highlighted,
)
from modules.os_helper import current_executor_path, move, path_join


def separate_audio(input_file_path: str, output_file: str, device="cpu") -> None:
    """Separate vocals from audio with demucs."""

    print(
        f"{ULTRASINGER_HEAD} Separating vocals from audio with {blue_highlighted('demucs')} and {red_highlighted(device)} as worker."
    )
    # Model selection?
    # -n htdemucs_ft
    subprocess.run(
        ["demucs", "-d", device, "--two-stems=vocals", "--float32", input_file_path]
    )
    separated_folder = path_join(current_executor_path(), "separated")
    move(separated_folder, output_file)