當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。