From 26367e3497d198263a133d7f5561c6912d38a43b Mon Sep 17 00:00:00 2001 From: Joel Mathew Thomas <90510078+joelmathewthomas@users.noreply.github.com> Date: Tue, 25 Feb 2025 20:50:30 +0530 Subject: [PATCH] bugfix: use parameter mono only if passed explicitly Caused the tests/test_separation to fail. --- src/freqsplit/input/file_reader.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/freqsplit/input/file_reader.py b/src/freqsplit/input/file_reader.py index 20c8c8a..5b6723a 100644 --- a/src/freqsplit/input/file_reader.py +++ b/src/freqsplit/input/file_reader.py @@ -1,7 +1,7 @@ import os import librosa -def read_audio(file_path, sr=None, mono=False): +def read_audio(file_path, sr=None, mono=None): """ Reads an audio file and returns the audio time series and sampling rate. @@ -17,7 +17,11 @@ def read_audio(file_path, sr=None, mono=False): if not os.path.exists(file_path): raise FileNotFoundError(f"File not found: {file_path}") try: - audio, sr = librosa.load(file_path, sr=sr, mono=mono) # Load with original sampling rate. + librosa_kwargs = {"sr": sr} + if mono is not None: # Only add 'mono' if explicitly provided + librosa_kwargs["mono"] = mono + + audio, sr = librosa.load(file_path, **librosa_kwargs) return audio, sr except Exception as e: raise RuntimeError(f"Error reading the audio file: {e}") \ No newline at end of file