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