當前位置: 首頁>>代碼示例>>Python>>正文


Python signal.stft方法代碼示例

本文整理匯總了Python中scipy.signal.stft方法的典型用法代碼示例。如果您正苦於以下問題:Python signal.stft方法的具體用法?Python signal.stft怎麽用?Python signal.stft使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy.signal的用法示例。


在下文中一共展示了signal.stft方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import stft [as 別名]
def __init__(self, filename, in_memory=True, window_size=4096,
                 output_size=84, feature_size=1024, sample_freq=11000,
                 complex_=False, fourier=False, stft=False, fast_load=False,
                 rng=None, seed=123):
        if not in_memory:
            raise NotImplementedError
        self.filename = filename

        self.window_size = window_size
        self.output_size = output_size
        self.feature_size = feature_size
        self.sample_freq = sample_freq
        self.complex_ = complex_
        self.fourier = fourier
        self.stft = stft
        self.fast_load = fast_load

        if rng is not None:
            self.rng = rng
        else:
            self.rng = numpy.random.RandomState(seed)

        self._train_data = {}
        self._valid_data = {}
        self._test_data = {}
        self._loaded = False

        self._eval_sets = {} 
開發者ID:ChihebTrabelsi,項目名稱:deep_complex_networks,代碼行數:30,代碼來源:dataset.py

示例2: aggregate_raw_batch

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import stft [as 別名]
def aggregate_raw_batch(self, features, output):
        """Aggregate batch.

        All post processing goes here.

        Parameters:
        -----------
        features : 3D float tensor
            Input tensor
        output : 2D integer tensor
            Output classes

        """
        channels = 2 if self.complex_ else 1
        features_out = numpy.zeros(
            [features.shape[0], self.window_size, channels])
        if self.fourier:
            if self.complex_:
                data = fft(features, axis=1)
                features_out[:, :, 0] = numpy.real(data[:, :, 0])
                features_out[:, :, 1] = numpy.imag(data[:, :, 0])
            else:
                data = numpy.abs(fft(features, axis=1))
                features_out = data
        elif self.stft:
            _, _, data = stft(features, nperseg=120, noverlap=60, axis=1)
            length = data.shape[1]
            n_feats = data.shape[3]
            if self.complex_:
                features_out = numpy.zeros(
                    [len(self.train_data), length, n_feats * 2])
                features_out[:, :, :n_feats] = numpy.real(data)
                features_out[:, :, n_feats:] = numpy.imag(data)
            else:
                features_out = numpy.abs(data[:, :, 0, :])
        else:
            features_out = features
        return features_out, output 
開發者ID:ChihebTrabelsi,項目名稱:deep_complex_networks,代碼行數:40,代碼來源:dataset.py

示例3: test_istft

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import stft [as 別名]
def test_istft(ctx, window_size, stride, fft_size, window_type, center):
    backend = ctx.backend[0].split(":")[0]
    if backend == 'cuda':
        pytest.skip('CUDA Convolution N-D is only supported in CUDNN extension')

    # clear all previous STFT conv/deconv kernels
    nn.clear_parameters()

    # Make sure that iSTFT(STFT(x)) = x
    x = np.random.randn(1, window_size * 10)

    nx = nn.Variable.from_numpy_array(x)
    with nn.context_scope(ctx):
        nyr, nyi = F.stft(nx,
                          window_size=window_size,
                          stride=stride,
                          fft_size=fft_size,
                          window_type=window_type,
                          center=center)
        nz = F.istft(nyr, nyi,
                     window_size=window_size,
                     stride=stride,
                     fft_size=fft_size,
                     window_type=window_type,
                     center=center)
    nz.forward()

    invalid = window_size - stride
    assert(np.allclose(nx.d[:, invalid:-invalid],
                       nz.d[:, invalid:-invalid],
                       atol=1e-5, rtol=1e-5)) 
開發者ID:sony,項目名稱:nnabla,代碼行數:33,代碼來源:test_stft.py

示例4: stft

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import stft [as 別名]
def stft(x, frame_len=2048, frame_step=512):
    return _stft(x, nperseg=frame_len, noverlap=(frame_len - frame_step))[-1] 
開發者ID:Enny1991,項目名稱:beamformers,代碼行數:4,代碼來源:beamformers.py

示例5: test_stft

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import stft [as 別名]
def test_stft(ctx, window_size, stride, fft_size, window_type):
    backend = ctx.backend[0].split(":")[0]
    if backend == 'cuda':
        pytest.skip('CUDA Convolution N-D is only supported in CUDNN extension')

    # clear all previous STFT conv/deconv kernels
    nn.clear_parameters()

    # Compare to `scipy.signal.stft` - only done if SciPy available
    x = np.random.randn(1, window_size * 10)

    nx = nn.Variable.from_numpy_array(x)

    with nn.context_scope(ctx):
        nyr, nyi = F.stft(nx,
                          window_size=window_size,
                          stride=stride,
                          fft_size=fft_size,
                          window_type=window_type,
                          center=False)
    nn.forward_all([nyr, nyi])

    stft_nnabla = nyr.d + 1j * nyi.d

    window_type_scipy = window_type
    if window_type == 'rectangular' or window_type is None:
        window_type_scipy = 'boxcar'

    _f, _t, stft_scipy = sig.stft(x,
                                  window=window_type_scipy,
                                  nperseg=window_size,
                                  noverlap=window_size-stride,
                                  nfft=fft_size,
                                  boundary=None,
                                  padded=False)

    # scipy does a different scaling - take care here
    stft_nnabla /= fft_size // 2

    assert(np.allclose(stft_nnabla,
                       stft_scipy,
                       atol=1e-5, rtol=1e-5)) 
開發者ID:sony,項目名稱:nnabla,代碼行數:44,代碼來源:test_stft.py


注:本文中的scipy.signal.stft方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。