@@ -86,7 +86,9 @@ def __init__(
86
86
87
87
self .output_single_stem = output_single_stem
88
88
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" )
90
92
91
93
self .chunks = 0
92
94
self .margin = 44100
@@ -170,15 +172,15 @@ def separate(self):
170
172
171
173
output_files = []
172
174
173
- if self .output_single_stem != "secondary" :
175
+ if not self .output_single_stem or self . output_single_stem . lower () == self . primary_stem . lower () :
174
176
self .logger .info (f"Saving { self .primary_stem } stem..." )
175
177
primary_stem_path = os .path .join (f"{ self .audio_file_base } _({ self .primary_stem } )_{ self .model_name } .{ self .output_format .lower ()} " )
176
178
if not isinstance (self .primary_source , np .ndarray ):
177
179
self .primary_source = spec_utils .normalize (self .logger , source , self .normalization_enabled ).T
178
180
self .write_audio (primary_stem_path , self .primary_source , samplerate )
179
181
output_files .append (primary_stem_path )
180
182
181
- if self .output_single_stem != "primary" :
183
+ if not self .output_single_stem or self . output_single_stem . lower () == self . secondary_stem . lower () :
182
184
self .logger .info (f"Saving { self .secondary_stem } stem..." )
183
185
secondary_stem_path = os .path .join (
184
186
f"{ self .audio_file_base } _({ self .secondary_stem } )_{ self .model_name } .{ self .output_format .lower ()} "
0 commit comments