当前位置: 首页>>代码示例>>Python>>正文


Python pyworld.synthesize方法代码示例

本文整理汇总了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 
开发者ID:k2kobayashi,项目名称:sprocket,代码行数:26,代码来源:synthesizer.py

示例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 
开发者ID:leimao,项目名称:Voice_Converter_CycleGAN,代码行数:10,代码来源:preprocess.py

示例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) 
开发者ID:k2kobayashi,项目名称:sprocket,代码行数:17,代码来源:analyzer.py

示例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 
开发者ID:k2kobayashi,项目名称:sprocket,代码行数:43,代码来源:synthesizer.py

示例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) 
开发者ID:Hiroshiba,项目名称:realtime-yukarin,代码行数:15,代码来源:vocoder.py

示例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) 
开发者ID:Hiroshiba,项目名称:become-yukarin,代码行数:15,代码来源:vocoder.py

示例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) 
开发者ID:Hiroshiba,项目名称:become-yukarin,代码行数:17,代码来源:super_resolution.py

示例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) 
开发者ID:Hiroshiba,项目名称:become-yukarin,代码行数:15,代码来源:acoustic_converter.py

示例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 
开发者ID:njellinas,项目名称:GAN-Voice-Conversion,代码行数:9,代码来源:speech_tools.py

示例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) 
开发者ID:Hiroshiba,项目名称:yukarin,代码行数:11,代码来源:acoustic_converter.py

示例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) 
开发者ID:Hiroshiba,项目名称:yukarin,代码行数:12,代码来源:acoustic_feature.py

示例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') 
开发者ID:JeremyCCHsu,项目名称:Python-Wrapper-for-World-Vocoder,代码行数:50,代码来源:demo.py


注:本文中的pyworld.synthesize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。