import subprocess import sys def install(package): subprocess.checkcall([sys.executable,…
- User
import subprocess import sys
def install(package): subprocess.check_call([sys.executable, "-m", "pip", "install", package])
Ensure that spleeter is installed
try: import spleeter except ImportError: install('spleeter')
from spleeter.separator import Separator
def extract_stems(input_file, output_path, stems=2): """ Extracts the audio stems from a given audio file using spleeter.
Parameters: input_file (str): The path to the audio file you want to process. output_path (str): The path where the stems will be saved. stems (int): The number of stems to extract. Can be 2, 4, or 5. """ # Use the 'spleeter' command via subprocess to avoid any potential library clashes in the environment try: separator = Separator(f'spleeter:{stems}stems') separator.separate_to_file(input_file, output_path) print(f'Stems extracted successfully to {output_path}') except Exception as e: print(f'An error occurred: {e}')Example usage
extract_stems('childhood bedroom.m4a', 'output', stems=5)
after splitting the stems , the audio quality of each stem is very poor. I need cd quality 16-bit 44.1khz from deezer i will give my token if needed:
- Assistant
- User
what is the maximum stems?
- Assistant
As of my knowledge cutoff date in early 2023, the Spleeter model by Deezer is capable of separating audio into a maximum of 5 stems. These stems typically include vocals, drums, bass, piano, and other accompaniment (often everything else that doesn't fall into the first four categories).
The pre-trained models provided by Spleeter are for:
- 2 stems: vocals and accompaniment
- 4 stems: vocals, drums, bass, and other
- 5 stems: vocals, drums, bass, piano, and other
These are the maximum available stems for the Spleeter library using the pre-trained models officially released by Deezer. If you require more specific or additional stems, this would involve either constructing a custom machine learning model trained for that specific purpose or using additional post-processing to further split the 'other' category, though neither of these options is provided out of the box with Spleeter.
- User
TypeError Traceback (most recent call last) in <cell line: 39>() 37 38 # Example usage ---> 39 extract_stems('This Is Heaven.m4a', 'output', stems=5)
in extract_stems(input_file, output_path, stems, config) 23 def extract_stems(input_file, output_path, stems=5, config=custom_config): 24 separator_config_string = f'spleeter:{stems}stems' ---> 25 separator = Separator(separator_config_string, params_descriptor=config) 26 separator.separate_to_file(input_file, output_path) 27 print(f'Stems extracted successfully to {output_path}')
TypeError: Separator.init() got multiple values for argument 'params_descriptor'
- Assistant
It seems that
Separatordoes not accept a custom configuration in the form of a dictionary directly. Instead, it expects the path to a YAML configuration file if you want to provide custom configuration parameters.