Defaults to 0 seconds.
if signal_length is not None and signal_starting_position >= signal_length:
raise IndexError("signal_starting_position cannot be greater than signal_length!")
try:
with audioread.audio_open(os.path.realpath(input_file_path)) as input_file:
self.sample_rate = input_file.samplerate
file_length = input_file.duration
n_ch = input_file.channels
read_mono = Trueif n_ch != 1:
read_mono = False
audio_input, self.sample_rate = librosa.load(input_file_path,
sr=input_file.samplerate,
offset=0,
duration=file_length,
mono=read_mono)
// Change from fixed point to floating point
if not np.issubdtype(audio_input.dtype, float):
audio_input = audio_input.astype("float") / (np.iinfo(audio_input.dtype).max + 1.0)
self.audio_data = audio_input
except Exception:
raise IOError("Cannot read from file, {file}".format(file=input_file_path))
self.path_to_input_file = input_file_path
self._active_end = signal_length if signal_length is not None else self._audio_data.shape[self._LEN]
self._active_start = signal_starting_position
def load_audio_from_array(self, signal, sample_rate=constants.DEFAULT_SAMPLE_RATE):
Loads an audio signal from a numpy array.