赞
踩
– 20230913
– 20230914
inflect==5.3.0 librosa==0.8.1 matplotlib==3.5.1 numpy==1.20.3 numba===0.51.2 Pillow==10.0.0 PyQt5==5.15.6 scikit-learn==1.0.2 scipy==1.7.3 sounddevice==0.4.3 SoundFile==0.10.3.post1 tqdm==4.66.1 umap-learn==0.5.2 Unidecode==1.3.2 urllib3==1.26.7 visdom==0.1.8.9 webrtcvad==2.0.10 lws==1.2.7 pysoundfile==0.9.0.post1
import os.path from IPython.core.display_functions import display from IPython.display import Audio from IPython.utils import io from synthesizer.inference import Synthesizer from encoder import inference as encoder from vocoder import inference as vocoder from pathlib import Path import numpy as np import librosa import soundfile as sf '''加载模型''' encoder_weights = Path("../saved_models/default/encoder.pt") vocoder_weights = Path("../saved_models/default/vocoder.pt") syn_dir = Path("../saved_models/default/synthesizer.pt") encoder.load_model(encoder_weights) synthesizer = Synthesizer(syn_dir) vocoder.load_model(vocoder_weights) def synth(text): '''根据文本,目标音频,调用模型合成语音''' #in_fpath = Path("./target-1.wav") in_fpath = os.path.join(r'E:\\Real-Time-Voice-Cloning\调用模型合成语音','652-130726-0004.flac') reprocessed_wav = encoder.preprocess_wav(in_fpath) original_wav, sampling_rate = librosa.load(in_fpath) preprocessed_wav = encoder.preprocess_wav(original_wav, sampling_rate) embed = encoder.embed_utterance(preprocessed_wav) print("Synthesizing new audio...") with io.capture_output() as captured: specs = synthesizer.synthesize_spectrograms([text], [embed]) generated_wav = vocoder.infer_waveform(specs[0]) generated_wav = np.pad(generated_wav, (0, synthesizer.sample_rate), mode="constant") #librosa.output.write_wav("output_trump_voice.wav", generated_wav, synthesizer.sample_rate) sf.write('output_trump_voice.wav', generated_wav, synthesizer.sample_rate, 'PCM_24') display(Audio(generated_wav, rate=synthesizer.sample_rate)) synth("oh......Hello, hahahahahaha, haven't seen you for a long time, how are you? what are you busy with recently?")
最终的效果:英文的声音还行,而且取决于你给的参考语音的效果好坏。
中文的稀碎......这个模型就不认识中文......
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。