本文整理匯總了Python中pyworld.synthesize方法的典型用法代碼示例。如果您正苦於以下問題:Python pyworld.synthesize方法的具體用法?Python pyworld.synthesize怎麽用?Python pyworld.synthesize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyworld
的用法示例。
在下文中一共展示了pyworld.synthesize方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: synthesis_spc
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def synthesis_spc(self, f0, spc, ap):
"""synthesis generates waveform from F0, mcep, ap
Parameters
----------
f0 : array, shape (`T`, `1`)
array of F0 sequence
spc : array, shape (`T`, `fftl // 2 + 1`)
array of mel-cepstrum sequence
ap : array, shape (`T`, `fftl // 2 + 1`)
array of aperiodicity
Return
------
wav: vector, shape (`samples`)
Synethesized waveform
"""
# generate waveform using world vocoder with f0, spc, ap
wav = pyworld.synthesize(f0, spc, ap,
self.fs, frame_period=self.shiftms)
return wav
示例2: world_speech_synthesis
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def world_speech_synthesis(f0, decoded_sp, ap, fs, frame_period):
#decoded_sp = decoded_sp.astype(np.float64)
wav = pyworld.synthesize(f0, decoded_sp, ap, fs, frame_period)
# Librosa could not save wav if not doing so
wav = wav.astype(np.float32)
return wav
示例3: synthesis
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def synthesis(self, f0, spc, ap):
"""Synthesis re-synthesizes a speech waveform from:
Parameters
----------
f0 : array, shape (`T`)
F0 sequence
spc : array, shape (`T`, `dim`)
Spectral envelope sequence
ap: array, shape (`T`, `dim`)
Aperiodicity sequence
"""
return pyworld.synthesize(f0, spc, ap, self.fs, frame_period=self.shiftms)
示例4: synthesis
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def synthesis(self, f0, mcep, ap, rmcep=None, alpha=0.42):
"""synthesis generates waveform from F0, mcep, aperiodicity
Parameters
----------
f0 : array, shape (`T`, `1`)
array of F0 sequence
mcep : array, shape (`T`, `dim`)
array of mel-cepstrum sequence
ap : array, shape (`T`, `fftlen / 2 + 1`) or (`T`, `dim_codeap`)
array of aperiodicity or code aperiodicity
rmcep : array, optional, shape (`T`, `dim`)
array of reference mel-cepstrum sequence
Default set to None
alpha : int, optional
Parameter of all-path transfer function
Default set to 0.42
Returns
----------
wav: array,
Synethesized waveform
"""
if rmcep is not None:
# power modification
mcep = mod_power(mcep, rmcep, alpha=alpha)
if ap.shape[1] < self.fftl // 2 + 1:
# decode codeap to ap
ap = pyworld.decode_aperiodicity(ap, self.fs, self.fftl)
# mcep into spc
spc = pysptk.mc2sp(mcep, alpha, self.fftl)
# generate waveform using world vocoder with f0, spc, ap
wav = pyworld.synthesize(f0, spc, ap,
self.fs, frame_period=self.shiftms)
return wav
示例5: decode
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def decode(
self,
acoustic_feature: AcousticFeature,
):
acoustic_feature = acoustic_feature.astype_only_float(numpy.float64)
out = pyworld.synthesize(
f0=acoustic_feature.f0.ravel(),
spectrogram=acoustic_feature.spectrogram,
aperiodicity=acoustic_feature.aperiodicity,
fs=self.out_sampling_rate,
frame_period=self.acoustic_param.frame_period,
)
return Wave(out, sampling_rate=self.out_sampling_rate)
示例6: decode
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def decode(
self,
acoustic_feature: AcousticFeature,
):
acoustic_feature = acoustic_feature.astype_only_float(numpy.float64)
out = pyworld.synthesize(
f0=acoustic_feature.f0.ravel(),
spectrogram=acoustic_feature.spectrogram,
aperiodicity=acoustic_feature.aperiodicity,
fs=self.out_sampling_rate,
frame_period=self.acoustic_feature_param.frame_period
)
return Wave(out, sampling_rate=self.out_sampling_rate)
示例7: convert_to_audio
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def convert_to_audio(
self,
input: numpy.ndarray,
acoustic_feature: AcousticFeature,
sampling_rate: int,
):
acoustic_feature = acoustic_feature.astype_only_float(numpy.float64)
out = pyworld.synthesize(
f0=acoustic_feature.f0.ravel(),
spectrogram=input.astype(numpy.float64),
aperiodicity=acoustic_feature.aperiodicity,
fs=sampling_rate,
frame_period=self._param.acoustic_feature_param.frame_period,
)
return Wave(out, sampling_rate=sampling_rate)
示例8: convert_from_feature
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def convert_from_feature(self, input: AcousticFeature, out_sampling_rate: Optional[int] = None):
if out_sampling_rate is None:
out_sampling_rate = self.config.dataset.param.voice_param.sample_rate
out = self.convert_to_feature(input=input, out_sampling_rate=out_sampling_rate)
out = pyworld.synthesize(
f0=out.f0.ravel(),
spectrogram=out.spectrogram,
aperiodicity=out.aperiodicity,
fs=out_sampling_rate,
frame_period=self._param.acoustic_feature_param.frame_period,
)
return Wave(out, sampling_rate=out_sampling_rate)
示例9: world_speech_synthesis
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def world_speech_synthesis(f0, decoded_sp, ap, fs, frame_period):
# decoded_sp = decoded_sp.astype(np.float64)
wav = pyworld.synthesize(f0, decoded_sp, ap, fs, frame_period)
# Librosa could not save wav if not doing so
wav = wav.astype(np.float32)
return wav
示例10: decode_acoustic_feature
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def decode_acoustic_feature(self, feature: AcousticFeature):
out = pyworld.synthesize(
f0=feature.f0.ravel().astype(numpy.float64),
spectrogram=feature.sp.astype(numpy.float64),
aperiodicity=feature.ap.astype(numpy.float64),
fs=self.out_sampling_rate,
frame_period=self._param.frame_period,
)
return Wave(out, sampling_rate=self.out_sampling_rate)
示例11: decode
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def decode(self, sampling_rate: int, frame_period: float):
acoustic_feature = self.astype_only_float(numpy.float64)
out = pyworld.synthesize(
f0=acoustic_feature.f0.ravel(),
spectrogram=acoustic_feature.sp,
aperiodicity=acoustic_feature.ap,
fs=sampling_rate,
frame_period=frame_period,
)
return Wave(out, sampling_rate=sampling_rate)
示例12: main
# 需要導入模塊: import pyworld [as 別名]
# 或者: from pyworld import synthesize [as 別名]
def main(args):
if os.path.isdir('test'):
rmtree('test')
os.mkdir('test')
x, fs = sf.read('utterance/vaiueo2d.wav')
# x, fs = librosa.load('utterance/vaiueo2d.wav', dtype=np.float64)
# 1. A convient way
f0, sp, ap = pw.wav2world(x, fs) # use default options
y = pw.synthesize(f0, sp, ap, fs, pw.default_frame_period)
# 2. Step by step
# 2-1 Without F0 refinement
_f0, t = pw.dio(x, fs, f0_floor=50.0, f0_ceil=600.0,
channels_in_octave=2,
frame_period=args.frame_period,
speed=args.speed)
_sp = pw.cheaptrick(x, _f0, t, fs)
_ap = pw.d4c(x, _f0, t, fs)
_y = pw.synthesize(_f0, _sp, _ap, fs, args.frame_period)
# librosa.output.write_wav('test/y_without_f0_refinement.wav', _y, fs)
sf.write('test/y_without_f0_refinement.wav', _y, fs)
# 2-2 DIO with F0 refinement (using Stonemask)
f0 = pw.stonemask(x, _f0, t, fs)
sp = pw.cheaptrick(x, f0, t, fs)
ap = pw.d4c(x, f0, t, fs)
y = pw.synthesize(f0, sp, ap, fs, args.frame_period)
# librosa.output.write_wav('test/y_with_f0_refinement.wav', y, fs)
sf.write('test/y_with_f0_refinement.wav', y, fs)
# 2-3 Harvest with F0 refinement (using Stonemask)
_f0_h, t_h = pw.harvest(x, fs)
f0_h = pw.stonemask(x, _f0_h, t_h, fs)
sp_h = pw.cheaptrick(x, f0_h, t_h, fs)
ap_h = pw.d4c(x, f0_h, t_h, fs)
y_h = pw.synthesize(f0_h, sp_h, ap_h, fs, pw.default_frame_period)
# librosa.output.write_wav('test/y_harvest_with_f0_refinement.wav', y_h, fs)
sf.write('test/y_harvest_with_f0_refinement.wav', y_h, fs)
# Comparison
savefig('test/wavform.png', [x, _y, y])
savefig('test/sp.png', [_sp, sp])
savefig('test/ap.png', [_ap, ap], log=False)
savefig('test/f0.png', [_f0, f0])
print('Please check "test" directory for output files')