def parse_audio(self, audio_path, audio=None, change_speed=None):
    if (audio is not None):
        y = audio
    elif self.speed_volume_perturb:
        y = load_randomly_augmented_audio(audio_path, self.sample_rate)
    else:
        y = load_audio(audio_path)
    if (change_speed is not None):
        y = librosa.effects.time_stretch(y, change_speed)
    if self.noiseInjector:
        add_noise = np.random.binomial(1, self.noise_prob)
        if add_noise:
            y = self.noiseInjector.inject_noise(y)
    n_fft = int((self.sample_rate * self.window_size))
    win_length = n_fft
    hop_length = int((self.sample_rate * self.window_stride))
    D = librosa.stft(y, n_fft=n_fft, hop_length=hop_length, win_length=win_length, window=self.window)
    (spect, phase) = librosa.magphase(D)
    spect = np.log1p(spect)
    spect = torch.FloatTensor(spect)
    if self.normalize:
        mean = spect.mean()
        std = spect.std()
        spect.add_((- mean))
        spect.div_(std)
    if self.spec_augment:
        spect = spec_augment(spect)
    return spect
def parse_audio(self, audio_path, audio=None, change_speed=None):
    if (audio is not None):
        y = audio
    elif self.speed_volume_perturb:
        y = load_randomly_augmented_audio(audio_path, self.sample_rate)
    else:
        y = load_audio(audio_path)
    if (change_speed is not None):
        y = librosa.effects.time_stretch(y, change_speed)
    if self.noiseInjector:
        add_noise = np.random.binomial(1, self.noise_prob)
        if add_noise:
            y = self.noiseInjector.inject_noise(y)
    n_fft = int((self.sample_rate * self.window_size))
    win_length = n_fft
    hop_length = int((self.sample_rate * self.window_stride))
    D = librosa.stft(y, n_fft=n_fft, hop_length=hop_length, win_length=win_length, window=self.window)
    (spect, phase) = librosa.magphase(D)
    spect = np.log1p(spect)
    spect = torch.FloatTensor(spect)
    if self.normalize:
        mean = spect.mean()
        std = spect.std()
        spect.add_((- mean))
        spect.div_(std)
    if self.spec_augment:
        spect = spec_augment(spect)
    return spect