本文整理汇总了Python中lws.lws方法的典型用法代码示例。如果您正苦于以下问题:Python lws.lws方法的具体用法?Python lws.lws怎么用?Python lws.lws使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lws
的用法示例。
在下文中一共展示了lws.lws方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import lws [as 别名]
# 或者: from lws import lws [as 别名]
def main():
data_foler = "data"
wavs = [os.path.join(data_foler, file[:-4]) for file in os.listdir(data_foler) if file.endswith(".wav")]
outputs_lws = [file + ".lws.gen.wav" for file in wavs]
wavs = [audio.load_wav(wav_path + ".wav", hparams.sample_rate) for wav_path in wavs]
lws_processor = lws.lws(512, 128, mode="speech") # 512: window length; 128: window shift
i = 0
for x in wavs:
X = lws_processor.stft(x) # where x is a single-channel waveform
X0 = np.abs(X) # Magnitude spectrogram
print('{:6}: {:5.2f} dB'.format('Abs(X)', lws_processor.get_consistency(X0)))
X1 = lws_processor.run_lws(
X0) # reconstruction from magnitude (in general, one can reconstruct from an initial complex spectrogram)
print(X1.shape)
print('{:6}: {:5.2f} dB'.format('LWS', lws_processor.get_consistency(X1)))
print(X1.shape)
wav = lws_processor.istft(X1).astype(np.float32)
audio.save_wav(wav, outputs_lws[i])
i += 1
示例2: _lws_processor
# 需要导入模块: import lws [as 别名]
# 或者: from lws import lws [as 别名]
def _lws_processor(hparams):
import lws
return lws.lws(hparams.n_fft, get_hop_size(hparams), fftsize=hparams.win_size, mode="speech")
示例3: _istft
# 需要导入模块: import lws [as 别名]
# 或者: from lws import lws [as 别名]
def _istft(y, hparams):
return librosa.istft(y, hop_length=get_hop_size(hparams), win_length=hparams.win_size)
##########################################################
#Those are only correct when using lws!!! (This was messing with Wavenet quality for a long time!)
示例4: _lws_processor
# 需要导入模块: import lws [as 别名]
# 或者: from lws import lws [as 别名]
def _lws_processor(hparams):
import lws
return lws.lws(hparams.fft_size, get_hop_size(hparams), fftsize=hparams.win_size, mode="speech")
示例5: _istft
# 需要导入模块: import lws [as 别名]
# 或者: from lws import lws [as 别名]
def _istft(y, hparams):
return librosa.istft(y, hop_length=get_hop_size(hparams), win_length=hparams.win_size)
##########################################################
#Those are only correct when using lws!!! (This was messing with Wavenet quality for a long time!)
示例6: _lws_processor
# 需要导入模块: import lws [as 别名]
# 或者: from lws import lws [as 别名]
def _lws_processor():
return lws.lws(hparams.fft_size, hparams.hop_size, mode="speech")
# Conversions:
示例7: _lws_processor
# 需要导入模块: import lws [as 别名]
# 或者: from lws import lws [as 别名]
def _lws_processor():
return lws.lws(hparams.fft_size, get_hop_size(), mode="speech")
示例8: lws_num_frames
# 需要导入模块: import lws [as 别名]
# 或者: from lws import lws [as 别名]
def lws_num_frames(length, fsize, fshift):
"""Compute number of time frames of lws spectrogram
"""
pad = (fsize - fshift)
if length % fshift == 0:
M = (length + pad * 2 - fsize) // fshift + 1
else:
M = (length + pad * 2 - fsize) // fshift + 2
return M
示例9: lws_pad_lr
# 需要导入模块: import lws [as 别名]
# 或者: from lws import lws [as 别名]
def lws_pad_lr(x, fsize, fshift):
"""Compute left and right padding lws internally uses
"""
M = lws_num_frames(len(x), fsize, fshift)
pad = (fsize - fshift)
T = len(x) + 2 * pad
r = (M - 1) * fshift + fsize - T
return pad, pad + r
# Conversions: