当前位置: 首页>>代码示例>>Python>>正文


Python signal.hamming方法代码示例

本文整理汇总了Python中scipy.signal.hamming方法的典型用法代码示例。如果您正苦于以下问题:Python signal.hamming方法的具体用法?Python signal.hamming怎么用?Python signal.hamming使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.signal的用法示例。


在下文中一共展示了signal.hamming方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import hamming [as 别名]
def __init__(self, win_len=0.025, win_step=0.01,
                 num_filt=40, nfft=512, low_freq=20, high_freq=7800,
                 pre_emph=0.97, win_fun=signal.hamming, **kwargs):

        super(FBank, self).__init__(**kwargs)

        if high_freq > self.fs / 2:
            raise ValueError("high_freq must be less or equal than fs/2")

        self.win_len = win_len
        self.win_step = win_step
        self.num_filt = num_filt
        self.nfft = nfft
        self.low_freq = low_freq
        self.high_freq = high_freq or self.fs / 2
        self.pre_emph = pre_emph
        self.win_fun = win_fun
        self._filterbanks = self._get_filterbanks()

        self._num_feats = self.num_filt 
开发者ID:igormq,项目名称:asr-study,代码行数:22,代码来源:audio.py

示例2: initialize

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import hamming [as 别名]
def initialize(self):
        f_matrix = np.fft.fft(np.eye(self.sz), norm='ortho')
        w = sig.hamming(self.sz)

        f_matrix_real = (np.real(f_matrix) * w).astype(np.float32, copy=False)
        f_matrix_imag = (np.imag(f_matrix) * w).astype(np.float32, copy=False)

        if torch.has_cudnn:
            self.conv_analysis_real.weight.data.copy_(torch.from_numpy(f_matrix_real[:, None, :]).cuda())
            self.conv_analysis_imag.weight.data.copy_(torch.from_numpy(f_matrix_imag[:, None, :]).cuda())
        else:
            self.conv_analysis_real.weight.data.copy_(torch.from_numpy(f_matrix_real[:, None, :]))
            self.conv_analysis_imag.weight.data.copy_(torch.from_numpy(f_matrix_imag[:, None, :])) 
开发者ID:drscotthawley,项目名称:signaltrain,代码行数:15,代码来源:cls_fe_dft.py

示例3: GLA

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import hamming [as 别名]
def GLA(wsz, hop, N=4096):
        """ LSEE-MSTFT algorithm for computing the synthesis window used in
        inverse STFT method.
        Args:
            wsz :   (int)    Synthesis window size
            hop :   (int)    Hop size
            N   :   (int)    DFT Size
        Returns :
            symw:   (array)  Synthesised windowing function
        References :
            [1] Daniel W. Griffin and Jae S. Lim, ``Signal estimation from modified short-time
            Fourier transform,'' IEEE Transactions on Acoustics, Speech and Signal Processing,
            vol. 32, no. 2, pp. 236-243, Apr 1984.
        """
        synw = sig.hamming(wsz)
        synwProd = synw ** 2.
        synwProd.shape = (wsz, 1)
        redundancy = wsz // hop
        env = np.zeros((wsz, 1))
        for k in range(-redundancy, redundancy + 1):
            envInd = (hop * k)
            winInd = np.arange(1, wsz + 1)
            envInd += winInd
            valid = np.where((envInd > 0) & (envInd <= wsz))
            envInd = envInd[valid] - 1
            winInd = winInd[valid] - 1
            env[envInd] += synwProd[winInd]

        synw = synw / env[:, 0]
        return synw 
开发者ID:drscotthawley,项目名称:signaltrain,代码行数:32,代码来源:cls_fe_dft.py

示例4: normhamming

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import hamming [as 别名]
def normhamming(fft_len):
    win = numpy.sqrt(hamming(fft_len, False))
    win = win/numpy.sqrt(numpy.sum(numpy.power(win[0:fft_len:FRAME_SHIFT],2)))
    return win 
开发者ID:xuchenglin28,项目名称:speaker_extraction,代码行数:6,代码来源:normhamming.py

示例5: _gl_alg

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import hamming [as 别名]
def _gl_alg(window_size, hop, fft_size=4096):
    """LSEE-MSTFT algorithm for computing the synthesis window.

    According to: Daniel W. Griffin and Jae S. Lim, `Signal estimation\
    from modified short-time Fourier transform,` IEEE Transactions on\
    Acoustics, Speech and Signal Processing, vol. 32, no. 2, pp. 236-243,\
    Apr 1984.

    :param window_size: Synthesis window size in samples.
    :type window_size: int
    :param hop: Hop size in samples.
    :type hop: int
    :param fft_size: FTT size
    :type fft_size: int
    :return: The synthesized window
    :rtype: numpy.core.multiarray.ndarray
    """
    syn_w = signal.hamming(window_size) / np.sqrt(fft_size)
    syn_w_prod = syn_w ** 2.
    syn_w_prod.shape = (window_size, 1)
    redundancy = int(window_size / hop)
    env = np.zeros((window_size, 1))

    for k in range(-redundancy, redundancy + 1):
        env_ind = (hop * k)
        win_ind = np.arange(1, window_size + 1)
        env_ind += win_ind

        valid = np.where((env_ind > 0) & (env_ind <= window_size))
        env_ind = env_ind[valid] - 1
        win_ind = win_ind[valid] - 1
        env[env_ind] += syn_w_prod[win_ind]

    syn_w = syn_w / env[:, 0]

    return syn_w 
开发者ID:SwagLyrics,项目名称:autosynch,代码行数:38,代码来源:signal_transforms.py

示例6: GLA

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import hamming [as 别名]
def GLA(wsz, hop):
        """ LSEE-MSTFT algorithm for computing the synthesis window used in
        inverse STFT method below.
        Args:
            wsz :   (int)    Synthesis Window size
            hop :   (int)    Hop size
        Returns :
            symw:   (array) Synthesised time-domain real signal.

        References :
            [1] Daniel W. Griffin and Jae S. Lim, ``Signal estimation from modified short-time
            Fourier transform,'' IEEE Transactions on Acoustics, Speech and Signal Processing,
            vol. 32, no. 2, pp. 236-243, Apr 1984.
        """
        synw = hamming(wsz)/np.sum(hamming(wsz))
        synwProd = synw ** 2.
        synwProd.shape = (wsz, 1)
        redundancy = wsz/hop
        env = np.zeros((wsz, 1))
        for k in xrange(-redundancy, redundancy + 1):
            envInd = (hop*k)
            winInd = np.arange(1, wsz+1)
            envInd += winInd

            valid = np.where((envInd > 0) & (envInd <= wsz))
            envInd = envInd[valid] - 1
            winInd = winInd[valid] - 1
            env[envInd] += synwProd[winInd]

        synw = synw/env[:, 0]
        return synw 
开发者ID:TUIlmenauAMS,项目名称:ASP,代码行数:33,代码来源:TFMethods.py

示例7: mfcc

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import hamming [as 别名]
def mfcc(s,fs, nfiltbank):
  
    #divide into segments of 25 ms with overlap of 10ms
    nSamples = np.int32(0.025*fs)
    overlap = np.int32(0.01*fs)
    nFrames = np.int32(np.ceil(len(s)/(nSamples-overlap)))
    #zero padding to make signal length long enough to have nFrames
    padding = ((nSamples-overlap)*nFrames) - len(s)
    if padding > 0:
        signal = np.append(s, np.zeros(padding))
    else:
        signal = s
    segment = np.empty((nSamples, nFrames))
    start = 0
    for i in range(nFrames):
        segment[:,i] = signal[start:start+nSamples]
        start = (nSamples-overlap)*i
    
    #compute periodogram
    nfft = 512
    periodogram = np.empty((nFrames, int(nfft/2 + 1)))
    for i in range(nFrames):
        x = segment[:,i] * hamming(nSamples)
        spectrum = fftshift(fft(x,nfft))
        periodogram[i,:] = abs(spectrum[int(nfft/2-1):])/nSamples
        
    #calculating mfccs    
    fbank = mel_filterbank(nfft, nfiltbank, fs)
    #nfiltbank MFCCs for each frame
    mel_coeff = np.empty((nfiltbank,nFrames))
    for i in range(nfiltbank):
        for k in range(nFrames):
            mel_coeff[i,k] = np.sum(periodogram[k,:]*fbank[:,i])
            
    mel_coeff = np.log10(mel_coeff)
    mel_coeff = dct(mel_coeff)
    #exclude 0th order coefficient (much larger than others)
    mel_coeff[0,:]= np.zeros(nFrames)
    return mel_coeff 
开发者ID:orchidas,项目名称:Speaker-Recognition,代码行数:41,代码来源:mel_coefficients.py

示例8: data_feeder_testing

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import hamming [as 别名]
def data_feeder_testing(window_size, fft_size, hop_size, seq_length, context_length,
                        batch_size, debug, sources_list=None):
    """Provides an iterator over the testing examples.

    :param window_size: The window size to be used for the time-frequency transformation.
    :type window_size: int
    :param fft_size: The size of the FFT in samples.
    :type fft_size: int
    :param hop_size: The hop size in samples.
    :type hop_size: int
    :param seq_length: The sequence length in frames.
    :type seq_length: int
    :param context_length: The context length in frames.
    :type context_length: int
    :param batch_size: The batch size.
    :type batch_size: int
    :param debug: A flag to indicate debug
    :type debug: bool
    :param sources_list: The file list provided for using the MaD-TwinNet.
    :type sources_list: list[str]
    :return: An iterator that will provide the input and target values.\
             The iterator yields (mix, mix magnitude, mix phase, voice true, bg true) values.
    :rtype: callable
    """
    if sources_list is None:
        usage_case = False
        sources_list = _get_files_lists('testing')[-1]
    else:
        usage_case = True
    hamming_window = signal.hamming(window_size, True)

    def testing_it():

        for index in range(len(sources_list)):
            yield _get_data_testing(
                sources_parent_path=sources_list[index],
                window_values=hamming_window, fft_size=fft_size, hop=hop_size,
                seq_length=seq_length, context_length=context_length,
                batch_size=batch_size, usage_case=usage_case
            )

            if debug:
                break

    return testing_it 
开发者ID:SwagLyrics,项目名称:autosynch,代码行数:47,代码来源:data_feeder.py


注:本文中的scipy.signal.hamming方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。