Beispiel #1
0
def make_wav(path_list, enhanced_wav_dir):
    for path in path_list:
        uttid, feat_path, angle_path = path
        feat_mat = kaldi_io.read_mat(feat_path)
        angle_mat = kaldi_io.read_mat(angle_path)
        image = np.sin(angle_mat) * feat_mat
        real = np.cos(angle_mat) * feat_mat
        result = 1j * image
        result += real
        D = librosa.istft(result,
                          n_fft=512,
                          hop_length=256,
                          win_length=512,
                          window=scipy.signal.hamming)
        wav_file = os.path.join(enhanced_wav_dir, uttid + '.wav')
        wav.write(wav_file, 16000, D)
 def extract_kaldi_feat(self, feat_path, feat_type='kaldi_magspec'):
     try:
         utt_mat = kaldi_io.read_mat(feat_path)
         ##utt_mat = utt_mat[:, :256]
         if feat_type == 'kaldi_magspec':
             spect = utt_mat
         elif feat_type == 'kaldi_powspec':
             spect = np.square(utt_mat)
         return spect
     except:
         print(feat_path, 'extract_kaldi_feat error')
         return None
Beispiel #3
0
    def load_feat(self, feat_path, delta_order=0):
        try:
            if "ark:" in feat_path:
                feat = kaldi_io.read_mat(feat_path)
            else:
                feat = np.load(feat_path)

            if feat is not None and delta_order > 0:
                feat = add_delta(feat, delta_order)
        except:
            #print('{} has error'.format(feat_path))
            feat = None
        return feat