本文整理匯總了Python中hparams.hparams.frame_length_ms方法的典型用法代碼示例。如果您正苦於以下問題:Python hparams.frame_length_ms方法的具體用法?Python hparams.frame_length_ms怎麽用?Python hparams.frame_length_ms使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hparams.hparams
的用法示例。
在下文中一共展示了hparams.frame_length_ms方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: spectrogram2wav
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import frame_length_ms [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
示例2: _stft_parameters
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import frame_length_ms [as 別名]
def _stft_parameters():
n_fft = (hparams.num_freq - 1) * 2
hop_length = int(hparams.frame_shift_ms / 1000 * hparams.sample_rate)
win_length = int(hparams.frame_length_ms / 1000 * hparams.sample_rate)
return n_fft, hop_length, win_length
# Conversions:
示例3: _stft_parameters
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import frame_length_ms [as 別名]
def _stft_parameters():
n_fft = (hps.num_freq - 1) * 2
hop_length = int(hps.frame_shift_ms / 1000 * hps.sample_rate)
win_length = int(hps.frame_length_ms / 1000 * hps.sample_rate)
return n_fft, hop_length, win_length
# Conversions: