def f_xvector(self, wavefile, kargs): kpath = kargs.get('kpath', '') k = kargs.get('ndim', 15) assert os.path.isfile(kpath), 'kpath not exit' assert os.path.isfile(wavefile), 'wav not exit' (rate, sig) = self.__readwav(wavefile) feat1 = idctcoeff(sig, rate, self.p_win_len, self.p_win_step, self.p_pre_emphasis_coeff) return _merge_feat(feat1, kpath, k)
def f_hdcc_fs(self, wavefile): (rate, sig) = self.__readwav(wavefile) feat1 = idctcoeff(sig, rate, self.p_win_len, self.p_win_step, self.p_pre_emphasis_coeff) row, clm = feat1.shape spl = [ 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000 ] xishu = list(sorted([int(rate / x) for x in spl] + [0])) feat = np.zeros((row, len(spl))) for i in range(len(xishu) - 1): st = int(xishu[i]) ed = int(xishu[i + 1]) bst = feat1[:, st:ed] liclist1 = np.sum(bst, axis=1) if len(liclist1) == 0: continue feat[:, i] = liclist1 return feat
def f_hdcc_mel(self, wavefile): (rate, sig) = self.__readwav(wavefile) feat1 = idctcoeff(sig, rate, self.p_win_len, self.p_win_step, self.p_pre_emphasis_coeff) row, clm = feat1.shape hzrange = 1000.0 spl = [ 0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000 ] melspl = [utils.hz2mel(xx) for xx in spl] splhzhigh = utils.hz2mel(hzrange) xishu = [x * clm / splhzhigh for x in melspl] feat = np.zeros((row, len(spl) - 1)) for i in range(len(xishu) - 1): st = int(xishu[i]) ed = int(xishu[i + 1]) bst = feat1[:, st:ed] liclist1 = np.sum(bst, axis=1) if len(liclist1) == 0: continue feat[:, i] = liclist1 return feat
def f_idct(self, wavefile): assert os.path.isfile(wavefile) (rate, sig) = self.__readwav(wavefile) return idctcoeff(sig, rate, self.p_win_len, self.p_win_step, self.p_pre_emphasis_coeff)