Skip to content

Commit 4c2f885

Browse files
authored
feat: Auto-enable override_model_segment_size for short audio in MDXC separator (#232)
1 parent c1d7ac7 commit 4c2f885

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

audio_separator/separator/architectures/mdxc_separator.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ def separate(self, audio_file_path, custom_output_names=None):
138138
self.logger.debug(f"Preparing mix for input audio file {self.audio_file_path}...")
139139
mix = self.prepare_mix(self.audio_file_path)
140140

141+
# Check if audio is shorter than threshold
142+
audio_duration_seconds = mix.shape[1] / self.sample_rate
143+
if audio_duration_seconds < 10.0:
144+
# Only change and warn if it wasn't already set by the user
145+
if not self.override_model_segment_size:
146+
self.override_model_segment_size = True
147+
self.logger.warning(f"Audio duration ({audio_duration_seconds:.2f}s) is less than 10 seconds.")
148+
self.logger.warning("Automatically enabling override_model_segment_size for better processing of short audio.")
149+
141150
self.logger.debug("Normalizing mix before demixing...")
142151
mix = spec_utils.normalize(wave=mix, max_peak=self.normalization_threshold, min_peak=self.amplification_threshold)
143152

0 commit comments

Comments
 (0)