1. 程式人生 > >librosa提取mel_fbank

librosa提取mel_fbank

eps = np.spacing(1)
magnitude_spectrogram = np.abs(librosa.stft(signal + eps,
                                                   n_fft=512,
                                                   hop_length=384,
                                                   center=True))**2#np.shape(magnitude_spectrogram)
                #signal = read_pcm(pcm_path) 
mel_basis = librosa.filters.mel(sr=16000,
                                    n_fft=512,
                                    n_mels=39)#np.shape(mel_basis)控制輸出個數
mel_spectrum = np.dot(mel_basis, magnitude_spectrogram)
logenergy = np.log(np.sum(magnitude_spectrogram, axis=0)).reshape(1,mel_spectrum.shape[1])
S = np.concatenate((librosa.logamplitude(mel_spectrum), logenergy), axis=0)#np.shape(S)