Пример #1
0
    def test_py_feat_interface(self):
        ''' test python feat interface '''
        sr_out, samples = speech_feature.load_wav(self.wavfile, sr=self.sr)
        self.assertEqual(sr_out, self.sr)

        pspec = speech_feature.powspec_feat(samples,
                                            sr=self.sr,
                                            nfft=self.nfft,
                                            winlen=self.winlen,
                                            winstep=self.winstep)
        self.assertEqual(pspec.shape, (426, 257))

        fbank = speech_feature.fbank_feat(pspec,
                                          feature_size=self.feature_size,
                                          sr=self.sr,
                                          nfft=self.nfft)
        self.assertEqual(fbank.shape, (426, 40))

        fbank = speech_feature.delta_delta(fbank, sr=self.sr)
        self.assertEqual(fbank.shape, (426, 40, 3))

        feat_ = speech_feature.extract_fbank(samples,
                                             sr=self.sr,
                                             winlen=self.winlen,
                                             winstep=self.winstep,
                                             feature_size=self.feature_size)
        self.assertEqual(feat_.shape, (426, 40, 3))

        samples = np.pad(samples, [0, 100], mode='constant')
        pspec = speech_feature.powspec_feat(samples,
                                            sr=self.sr,
                                            nfft=self.nfft,
                                            winlen=self.winlen,
                                            winstep=self.winstep)
        self.assertEqual(pspec.shape, (427, 257))
        fbank = speech_feature.fbank_feat(pspec,
                                          feature_size=self.feature_size,
                                          sr=self.sr,
                                          nfft=self.nfft)
        fbank = speech_feature.delta_delta(fbank, sr=self.sr)
        self.assertEqual(fbank.shape, (427, 40, 3))
Пример #2
0
  def test_py_extract_feat(self):
    ''' test python fbank with delta-delta interface '''
    speech_feature.extract_feat((self.wavfile),
                                winlen=self.winlen,
                                winstep=self.winstep,
                                sr=self.sr,
                                feature_size=self.feature_size,
                                nfft=self.nfft,
                                feat_type=self.feat_type)
    feat = np.load(self.featfile)
    self.assertEqual(feat.shape, (426, 40))

    feat = speech_feature.delta_delta(feat, sr=self.sr)
    self.assertEqual(feat.shape, (426, 40, 3))