예제 #1
0
    def test_mfcc(self):
        correct = rosaft.mfcc(y=self.sig,
                              sr=self.fs,
                              n_fft=nfft,
                              hop_length=stepsize)
        actual = mfcc(self.args)

        self.assertTrue(np.abs(correct - actual).max() < tol)
예제 #2
0
def extract_mfcc(wav_file_path, fs, start, end, nfft, noverlap, filepath=None):
    sig = wavfile.read_segment(wav_file_path,
                               beg_ms=start,
                               end_ms=end,
                               mono=True)
    args = dict(nfft=nfft,
                noverlap=noverlap,
                win_length=nfft,
                fs=fs,
                wav_file_path=None,
                start=0,
                end=None,
                sig=sig,
                center=True)
    value = mfcc(args)

    if filepath:
        with open(filepath, 'wb') as f:
            pickle.dump(value, f)
    else:
        return value