Skip to content

Commit 1b03178

Browse files
committed
Merge branch 'main' of github.com:nomadkaraoke/python-audio-separator
2 parents e842601 + 5c74a6d commit 1b03178

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

audio_separator/separator/common_separator.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ def write_audio_soundfile(self, stem_path: str, stem_source):
317317
"""
318318
self.logger.debug(f"Entering write_audio_soundfile with stem_path: {stem_path}")
319319

320+
stem_source = spec_utils.normalize(wave=stem_source, max_peak=self.normalization_threshold, min_peak=self.amplification_threshold)
321+
322+
# Check if the numpy array is empty or contains very low values
323+
if np.max(np.abs(stem_source)) < 1e-6:
324+
self.logger.warning("Warning: stem_source array is near-silent or empty.")
325+
return
326+
327+
# If output_dir is specified, create it and join it with stem_path
328+
if self.output_dir:
329+
os.makedirs(self.output_dir, exist_ok=True)
330+
stem_path = os.path.join(self.output_dir, stem_path)
331+
320332
# Correctly interleave stereo channels if needed
321333
if stem_source.shape[1] == 2:
322334
# If the audio is already interleaved, ensure it's in the correct order

0 commit comments

Comments
 (0)