Skip to content

Commit c8d8be8

Browse files
committed
Improved --single_stem parameter to be more intuitive, expecting "instrumental" or "vocals" rather than "primary" etc.
1 parent fff7342 commit c8d8be8

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

audio_separator/separator.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def __init__(
8686

8787
self.output_single_stem = output_single_stem
8888
if output_single_stem is not None:
89-
self.logger.debug(f"Single stem output requested, only one output file will be written: {output_single_stem}")
89+
if output_single_stem.lower() not in {"instrumental", "vocals"}:
90+
raise Exception("output_single_stem must be either 'instrumental' or 'vocals'")
91+
self.logger.debug(f"Single stem output requested, only one output file ({output_single_stem}) will be written")
9092

9193
self.chunks = 0
9294
self.margin = 44100
@@ -170,15 +172,15 @@ def separate(self):
170172

171173
output_files = []
172174

173-
if self.output_single_stem != "secondary":
175+
if not self.output_single_stem or self.output_single_stem.lower() == self.primary_stem.lower():
174176
self.logger.info(f"Saving {self.primary_stem} stem...")
175177
primary_stem_path = os.path.join(f"{self.audio_file_base}_({self.primary_stem})_{self.model_name}.{self.output_format.lower()}")
176178
if not isinstance(self.primary_source, np.ndarray):
177179
self.primary_source = spec_utils.normalize(self.logger, source, self.normalization_enabled).T
178180
self.write_audio(primary_stem_path, self.primary_source, samplerate)
179181
output_files.append(primary_stem_path)
180182

181-
if self.output_single_stem != "primary":
183+
if not self.output_single_stem or self.output_single_stem.lower() == self.secondary_stem.lower():
182184
self.logger.info(f"Saving {self.secondary_stem} stem...")
183185
secondary_stem_path = os.path.join(
184186
f"{self.audio_file_base}_({self.secondary_stem})_{self.model_name}.{self.output_format.lower()}"

audio_separator/utils/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def main():
7575
parser.add_argument(
7676
"--single_stem",
7777
default=None,
78-
help="Optional: output only single stem, primary or secondary. With the default model, primary is the instrumental. Example: --single_stem=primary",
78+
help="Optional: output only single stem, either instrumental or vocals. Example: --single_stem=instrumental",
7979
)
8080

8181
args = parser.parse_args()

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "audio-separator"
3-
version = "0.6.2"
3+
version = "0.6.3"
44
description = "Easy to use vocal separation on CLI or as a python package, using the amazing MDX-Net models from UVR trained by @Anjok07"
55
authors = ["Andrew Beveridge <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)