Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load_audio(self, path):
"""This require an audio input longer than 2.24s."""
fin = container.open(path)
audio_frames = [frame for frame in fin.decode()]
audios = list(map(lambda x: np.frombuffer(x.planes[0], self._format_dtypes[x.format.name],
x.samples), audio_frames))
audio = np.concatenate(audios, axis=0)
return nd.array(np.expand_dims(audio[:self._audio_length], axis=0))
def _load(path):
fin = container.open(path)
audio_frames = [frame for frame in fin.decode()]
audios = list(map(lambda x: np.frombuffer(x.planes[0], format_dtypes[x.format.name],
x.samples), audio_frames))
audio = np.concatenate(audios, axis=0)
return nd.array(audio)