def _wav2feats(wavname): """ Extract features for wav 16k mono """ ext = os.path.splitext(wavname)[-1] assert ext.lower() == '.wav' or ext.lower() == '.wave' sig, read_framerate, sampwidth = read_wav(wavname) shp = sig.shape # wav should contain a single channel assert len(shp) == 1 or (len(shp) == 2 and shp[1] == 1) # wav sample rate should be 16000 Hz assert read_framerate == 16000 # LP: to be checked when sampwidth == 4 # assert sampwidth == 2 sig *= (2**(15 - sampwidth)) with warnings.catch_warnings() as w: # ignore warnings resulting from empty signals parts warnings.filterwarnings('ignore', message='divide by zero encountered in log', category=RuntimeWarning, module='sidekit') _, loge, _, mspec = mfcc(sig.astype(np.float32), get_mspec=True) # Management of short duration segments difflen = 0 if len(loge) < 68: difflen = 68 - len(loge) warnings.warn( "media %s duration is short. Robust results require length of at least 720 milliseconds" % wavname) mspec = np.concatenate((mspec, np.ones((difflen, 24)) * np.min(mspec))) #loge = np.concatenate((loge, np.ones(difflen) * np.min(mspec))) return mspec, loge, difflen
def _wav2feats(wavname): """ """ ext = os.path.splitext(wavname)[-1] assert ext.lower() == '.wav' or ext.lower() == '.wave' sig, read_framerate, sampwidth = read_wav(wavname) shp = sig.shape # wav should contain a single channel assert len(shp) == 1 or (len(shp) == 2 and shp[1] == 1) # wav sample rate should be 16000 Hz assert read_framerate == 16000 sig *= (2**(15 - sampwidth)) _, loge, _, mspec = mfcc(sig.astype(np.float32), get_mspec=True) return mspec, loge
def _wav2feats(wavname): """ """ ext = os.path.splitext(wavname)[-1] assert ext.lower() == '.wav' or ext.lower() == '.wave' sig, read_framerate, sampwidth = read_wav(wavname) shp = sig.shape # wav should contain a single channel assert len(shp) == 1 or (len(shp) == 2 and shp[1] == 1) # wav sample rate should be 16000 Hz assert read_framerate == 16000 assert sampwidth == 2 sig *= (2**(15 - sampwidth)) with warnings.catch_warnings() as w: # ignore warnings resulting from empty signals parts warnings.filterwarnings('ignore', message='divide by zero encountered in log', category=RuntimeWarning, module='sidekit') _, loge, _, mspec = mfcc(sig.astype(np.float32), get_mspec=True) return mspec, loge