Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Returns:
tuple:
* **numpy.ndarray**: two-dimensional array with shape
`(channels, samples)`
* **int**: sample rate of the audio file
Example:
>>> signal, sampling_rate = load('speech.wav')
"""
signal = np.array([[]]) # empty signal of shape (1, 0)
sampling_rate = None
try:
signal, sampling_rate = af.read(filename,
duration=duration,
offset=offset,
always_2d=True)
except ValueError:
warn('File opening error for: {}'.format(filename), UserWarning)
except (IOError, FileNotFoundError):
warn('File does not exist: {}'.format(filename), UserWarning)
except RuntimeError:
warn('Runtime error for file: {}'.format(filename), UserWarning)
except subprocess.CalledProcessError:
warn('ffmpeg conversion failed for: {}'.format(filename), UserWarning)
return signal, sampling_rate