bugfix: use parameter mono only if passed explicitly
Caused the tests/test_separation to fail.
This commit is contained in:
@@ -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}")
|
||||
Reference in New Issue
Block a user