Views
No views yet
1git clone https://github.com/MYZY-AI/Muyan-TTS.git
2cd Muyan-TTS
3
4conda create -n muyan-tts python=3.10 -y
5conda activate muyan-tts
6make buildFFmpeg. If you're using Ubuntu, you can install it with the following command:1sudo apt update
2sudo apt install ffmpegpretrained_models directory. Your directory structure should look similar to the following:pretrained_models
├── chinese-hubert-base
├── Muyan-TTS
└── Muyan-TTS-SFTpython tts.py1async def main(model_type, model_path):
2 tts = Inference(model_type, model_path, enable_vllm_acc=False)
3 wavs = await tts.generate(
4 ref_wav_path="assets/Claire.wav",
5 prompt_text="Although the campaign was not a complete success, it did provide Napoleon with valuable experience and prestige.",
6 text="Welcome to the captivating world of podcasts, let's embark on this exciting journey together."
7 )
8 output_path = "logs/tts.wav"
9 with open(output_path, "wb") as f:
10 f.write(next(wavs))
11 print(f"Speech generated in {output_path}")ref_wav_path and its prompt_text, and the text to be synthesized. The synthesized speech is saved by default to logs/tts.wav.model_type as either base or sft, with the default being base.model_type to be base, you can change the prompt speech to arbitrary speaker for zero-shot TTS synthesis.model_type to be sft, you need to keep the prompt speech unchanged because the sft model is trained on Claire's voice.python api.py8020. Additionally, LLM logs will be saved in logs/llm.log.1import time
2import requests
3TTS_PORT=8020
4payload = {
5 "ref_wav_path": "assets/Claire.wav",
6 "prompt_text": "Although the campaign was not a complete success, it did provide Napoleon with valuable experience and prestige.",
7 "text": "Welcome to the captivating world of podcasts, let's embark on this exciting journey together."
8}
9start = time.time()
10
11url = f"http://localhost:{TTS_PORT}/get_tts"
12response = requests.post(url, json=payload)
13audio_file_path = "logs/tts.wav"
14with open(audio_file_path, "wb") as f:
15 f.write(response.content)
16
17print(time.time() - start)logs/tts.wav.model_type as either base or sft, with the default being base.LibriSpeech as an example. You can use your own dataset instead, but you need to organize the data into the format shown in data_process/examples.LibriSpeech yet, you can download the dev-clean set using:wget --no-check-certificate https://www.openslr.org/resources/12/dev-clean.tar.gzlibrispeech_dir in prepare_sft_dataset.py to match the download location. Then run:./train.shdata/tts_sft_data.json.data_process/text_format_conversion.py) as an example because its data size is relatively large. If you organize your own dataset for training, please prepare at least a dozen of minutes of speech from the target speaker.train.sh.data/tts_sft_data.json, train.sh will automatically copy it to llama-factory/data and add the following field to dataset_info.json:1"tts_sft_data": {
2 "file_name": "tts_sft_data.json"
3}llamafactory-cli train command to start training. You can adjust training settings using training/sft.yaml.pretrained_models/Muyan-TTS-new-SFT.sovits.pth of base/sft model to your trained model path before inference:cp pretrained_models/Muyan-TTS/sovits.pth pretrained_models/Muyan-TTS-new-SFTmodel_type to be sft and replace the ref_wav_path and prompt_text with a sample of the speaker's voice you trained on.