本文整理匯總了Python中hparams.hparams.ref_level_db方法的典型用法代碼示例。如果您正苦於以下問題:Python hparams.ref_level_db方法的具體用法?Python hparams.ref_level_db怎麽用?Python hparams.ref_level_db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hparams.hparams
的用法示例。
在下文中一共展示了hparams.ref_level_db方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: forward
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def forward(self, x):
if self.preemp is not None:
x = x.unsqueeze(1)
x = self.preemp(x)
x = x.squeeze(1)
stft = torch.stft(x,
self.win_length,
self.hop_length,
fft_size=self.n_fft,
window=self.win)
real = stft[:, :, :, 0]
im = stft[:, :, :, 1]
spec = torch.sqrt(torch.pow(real, 2) + torch.pow(im, 2))
# convert linear spec to mel
mel = torch.matmul(spec, self.mel_basis)
# convert to db
mel = _amp_to_db(mel) - hparams.ref_level_db
return _normalize(mel)
示例2: spectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def spectrogram(y):
D = _stft(_preemphasis(y))
S = _amp_to_db(np.abs(D)) - hparams.ref_level_db
return _normalize(S)
示例3: inv_spectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def inv_spectrogram(spectrogram):
S = _db_to_amp(_denormalize(spectrogram) + hparams.ref_level_db) # Convert back to linear
return _inv_preemphasis(_griffin_lim(S ** hparams.power)) # Reconstruct phase
示例4: inv_spectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def inv_spectrogram(spectrogram):
S = _db_to_amp(_denormalize(spectrogram) + hparams.ref_level_db) # Convert back to linear
return _inv_preemphasis(spectrogram2wav(S ** hparams.power)) # Reconstruct phase
示例5: spectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def spectrogram(y):
D = _stft(preemphasis(y))
S = _amp_to_db(np.abs(D)) - hparams.ref_level_db
return _normalize(S)
示例6: inv_spectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def inv_spectrogram(spectrogram):
'''Converts spectrogram to waveform using librosa'''
S = _db_to_amp(_denormalize(spectrogram) + hparams.ref_level_db) # Convert back to linear
return inv_preemphasis(_griffin_lim(S ** hparams.power)) # Reconstruct phase
示例7: inv_spectrogram_tensorflow
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def inv_spectrogram_tensorflow(spectrogram):
'''Builds computational graph to convert spectrogram to waveform using TensorFlow.
Unlike inv_spectrogram, this does NOT invert the preemphasis. The caller should call
inv_preemphasis on the output after running the graph.
'''
S = _db_to_amp_tensorflow(_denormalize_tensorflow(spectrogram) + hparams.ref_level_db)
return _griffin_lim_tensorflow(tf.pow(S, hparams.power))
示例8: melspectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def melspectrogram(y):
D = _stft(preemphasis(y))
S = _amp_to_db(_linear_to_mel(np.abs(D))) - hparams.ref_level_db
return _normalize(S)
示例9: linearspectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def linearspectrogram(wav):
D = _stft(wav)
S = _amp_to_db(np.abs(D)) - hparams.ref_level_db
if hparams.signal_normalization:
return _normalize(S)
return S
示例10: melspectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def melspectrogram(wav):
D = _stft(wav)
S = _amp_to_db(_linear_to_mel(np.abs(D))) - hparams.ref_level_db
if hparams.signal_normalization:
return _normalize(S)
return S
示例11: inv_linear_spectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def inv_linear_spectrogram(linear_spectrogram):
'''Converts linear spectrogram to waveform using librosa'''
if hparams.signal_normalization:
D = _denormalize(linear_spectrogram)
else:
D = linear_spectrogram
S = _db_to_amp(D + hparams.ref_level_db) #Convert back to linear
return _griffin_lim(S ** hparams.power)
示例12: inv_mel_spectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def inv_mel_spectrogram(mel_spectrogram):
'''Converts mel spectrogram to waveform using librosa'''
if hparams.signal_normalization:
D = _denormalize(mel_spectrogram)
else:
D = mel_spectrogram
S = _mel_to_linear(_db_to_amp(D + hparams.ref_level_db)) # Convert back to linear
return _griffin_lim(S ** hparams.power)
示例13: melspectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def melspectrogram(wav):
D = _stft(wav)
S = _amp_to_db(_linear_to_mel(np.abs(D))) - hparams.ref_level_db
if hparams.mel_normalization:
return _normalize(S)
return S
示例14: melspectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def melspectrogram(y):
D = _stft(y)
S = _amp_to_db(_linear_to_mel(np.abs(D))) - hparams.ref_level_db
if not hparams.allow_clipping_in_normalization:
assert S.max() <= 0 and S.min() - hparams.min_level_db >= 0
return _normalize(S)
示例15: spectrogram
# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import ref_level_db [as 別名]
def spectrogram(y):
D = _stft(y)
S = _amp_to_db(np.abs(D)) - hparams.ref_level_db
return _normalize(S)