예제 #1
0
def magspec(signal, samplerate, conf):
    '''
    Compute magnitude spectrogram features from an audio signal.

    Args:
        signal: the audio signal from which to compute features. Should be an
            N*1 array
        samplerate: the samplerate of the signal we are working with.
        conf: feature configuration

    Returns:
        A numpy array of size (NUMFRAMES by numfreq) containing features. Each
        row holds 1 feature vector, a numpy vector containing the magnitude
        spectrum of the corresponding frame
    '''
    signal = sigproc.preemphasis(signal, float(conf['preemph']))

    winfunc = _get_winfunc(conf['winfunc'])

    frames = sigproc.framesig(signal,
                              float(conf['winlen']) * samplerate,
                              float(conf['winstep']) * samplerate, winfunc)
    magspec = sigproc.magspec(frames, int(conf['nfft']))

    return magspec
예제 #2
0
 def do_mfcc(self, fft_n, mffc_ch):
     """ produces magnitude-> pow.spec on a freq scale """
     self.nfft = fft_n
     self.nmffc = mffc_ch
     self.mag = sigproc.magspec(self.samples, self.nfft)
     self.powspec2 = np.square(self.mag)
     self.powspec1 = sigproc.powspec(self.samples,self.nfft)        
     self.bank = get_filterbanks(nfilt=self.nmffc, nfft=self.nfft, samplerate=self.hz)
     self.mfc = np.dot(self.powspec1, self.bank.T)
     return self.mfc