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


Python hparams.griffin_lim_iters方法代碼示例

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


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

示例1: _griffin_lim

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import griffin_lim_iters [as 別名]
def _griffin_lim(S):
    angles = np.exp(2j * np.pi * np.random.rand(*S.shape))
    S_complex = np.abs(S).astype(np.complex)
    for i in range(hparams.griffin_lim_iters):
        if i > 0:
            angles = np.exp(1j * np.angle(_stft(y)))
        y = _istft(S_complex * angles)
    return y 
開發者ID:candlewill,項目名稱:Griffin_lim,代碼行數:10,代碼來源:audio.py

示例2: spectrogram2wav

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import griffin_lim_iters [as 別名]
def spectrogram2wav(spectrogram, n_iter=hparams.griffin_lim_iters, n_fft=(hparams.num_freq - 1) * 2,
                    win_length=int(hparams.frame_length_ms / 1000 * hparams.sample_rate),
                    hop_length=int(hparams.frame_shift_ms / 1000 * hparams.sample_rate)):
    '''Converts spectrogram into a waveform using Griffin-lim's raw.
    '''

    def invert_spectrogram(spectrogram):
        '''
        spectrogram: [t, f]
        '''
        spectrogram = tf.expand_dims(spectrogram, 0)
        inversed = tf.contrib.signal.inverse_stft(spectrogram, win_length, hop_length, n_fft)
        squeezed = tf.squeeze(inversed, 0)
        return squeezed

    spectrogram = tf.transpose(spectrogram)

    spectrogram = tf.cast(spectrogram, dtype=tf.complex64)  # [t, f]
    X_best = tf.identity(spectrogram)
    for i in range(n_iter):
        X_t = invert_spectrogram(X_best)
        est = tf.contrib.signal.stft(X_t, win_length, hop_length, n_fft, pad_end=False)  # (1, T, n_fft/2+1)
        phase = est / tf.cast(tf.maximum(1e-8, tf.abs(est)), tf.complex64)  # [t, f]
        X_best = spectrogram * phase  # [t, t]
    X_t = invert_spectrogram(X_best)
    y = tf.real(X_t)

    return y 
開發者ID:candlewill,項目名稱:Griffin_lim,代碼行數:30,代碼來源:griffin_lim.py

示例3: _griffin_lim

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import griffin_lim_iters [as 別名]
def _griffin_lim(S):
  '''librosa implementation of Griffin-Lim
  Based on https://github.com/librosa/librosa/issues/434
  '''
  angles = np.exp(2j * np.pi * np.random.rand(*S.shape))
  S_complex = np.abs(S).astype(np.complex)
  y = _istft(S_complex * angles)
  for i in range(hparams.griffin_lim_iters):
    angles = np.exp(1j * np.angle(_stft(y)))
    y = _istft(S_complex * angles)
  return y 
開發者ID:yanggeng1995,項目名稱:vae_tacotron,代碼行數:13,代碼來源:audio.py

示例4: _griffin_lim_tensorflow

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import griffin_lim_iters [as 別名]
def _griffin_lim_tensorflow(S):
  '''TensorFlow implementation of Griffin-Lim
  Based on https://github.com/Kyubyong/tensorflow-exercises/blob/master/Audio_Processing.ipynb
  '''
  with tf.variable_scope('griffinlim'):
    # TensorFlow's stft and istft operate on a batch of spectrograms; create batch of size 1
    S = tf.expand_dims(S, 0)
    S_complex = tf.identity(tf.cast(S, dtype=tf.complex64))
    y = _istft_tensorflow(S_complex)
    for i in range(hparams.griffin_lim_iters):
      est = _stft_tensorflow(y)
      angles = est / tf.cast(tf.maximum(1e-8, tf.abs(est)), tf.complex64)
      y = _istft_tensorflow(S_complex * angles)
    return tf.squeeze(y, 0) 
開發者ID:yanggeng1995,項目名稱:vae_tacotron,代碼行數:16,代碼來源:audio.py

示例5: _griffin_lim

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import griffin_lim_iters [as 別名]
def _griffin_lim(S):
	'''librosa implementation of Griffin-Lim
	Based on https://github.com/librosa/librosa/issues/434
	'''
	angles = np.exp(2j * np.pi * np.random.rand(*S.shape))
	S_complex = np.abs(S).astype(np.complex)
	y = _istft(S_complex * angles)
	for i in range(hparams.griffin_lim_iters):
		angles = np.exp(1j * np.angle(_stft(y)))
		y = _istft(S_complex * angles)
	return y 
開發者ID:rishikksh20,項目名稱:vae_tacotron2,代碼行數:13,代碼來源:audio.py


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