Update README.md
Browse files
README.md
CHANGED
|
@@ -1,39 +1,66 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
## 👉🏻 CosyVoice 👈🏻
|
| 4 |
-
**CosyVoice 2.0**: [Demos](https://funaudiollm.github.io/cosyvoice2/); [Paper](https://arxiv.org/abs/2412.10117); [Modelscope](https://www.modelscope.cn/studios/iic/CosyVoice2-0.5B); [HuggingFace](https://huggingface.co/spaces/FunAudioLLM/CosyVoice2-0.5B)
|
| 5 |
|
| 6 |
-
**CosyVoice
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
## Highlight🔥
|
| 9 |
|
| 10 |
-
**CosyVoice
|
| 11 |
-
###
|
| 12 |
-
- **
|
| 13 |
-
- **
|
| 14 |
-
|
| 15 |
-
- **
|
| 16 |
-
- **
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
- **Benchmark Achievements**: Attains the lowest character error rate on the hard test set of the Seed-TTS evaluation set.
|
| 20 |
-
### Strong Stability
|
| 21 |
-
- **Consistency in Timbre**: Ensures reliable voice consistency for zero-shot and cross-language speech synthesis.
|
| 22 |
-
- **Cross-language Synthesis**: Marked improvements compared to version 1.0.
|
| 23 |
-
### Natural Experience
|
| 24 |
-
- **Enhanced Prosody and Sound Quality**: Improved alignment of synthesized audio, raising MOS evaluation scores from 5.4 to 5.53.
|
| 25 |
-
- **Emotional and Dialectal Flexibility**: Now supports more granular emotional controls and accent adjustments.
|
| 26 |
|
| 27 |
## Roadmap
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
- [x] 2024/12
|
| 30 |
|
| 31 |
-
- [x] 25hz
|
| 32 |
|
| 33 |
- [x] 2024/09
|
| 34 |
|
| 35 |
-
- [x] 25hz
|
| 36 |
-
- [x] 25hz
|
| 37 |
|
| 38 |
- [x] 2024/08
|
| 39 |
|
|
@@ -46,65 +73,66 @@
|
|
| 46 |
- [x] WeTextProcessing support when ttsfrd is not available
|
| 47 |
- [x] Fastapi server and client
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
## Install
|
| 51 |
|
| 52 |
-
|
| 53 |
|
| 54 |
- Clone the repo
|
| 55 |
-
``` sh
|
| 56 |
-
git clone --recursive https://github.com/FunAudioLLM/CosyVoice.git
|
| 57 |
-
# If you failed to clone submodule due to network failures, please run following command until success
|
| 58 |
-
cd CosyVoice
|
| 59 |
-
git submodule update --init --recursive
|
| 60 |
-
```
|
| 61 |
|
| 62 |
- Install Conda: please see https://docs.conda.io/en/latest/miniconda.html
|
| 63 |
- Create Conda env:
|
| 64 |
|
| 65 |
-
``` sh
|
| 66 |
-
conda create -n cosyvoice python=3.10
|
| 67 |
-
conda activate cosyvoice
|
| 68 |
-
|
| 69 |
-
conda install -y -c conda-forge pynini==2.1.5
|
| 70 |
-
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
|
| 71 |
-
|
| 72 |
-
# If you encounter sox compatibility issues
|
| 73 |
-
# ubuntu
|
| 74 |
-
sudo apt-get install sox libsox-dev
|
| 75 |
-
# centos
|
| 76 |
-
sudo yum install sox sox-devel
|
| 77 |
-
```
|
| 78 |
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
|
| 82 |
|
| 83 |
``` python
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
snapshot_download('iic/CosyVoice2-0.5B', local_dir='pretrained_models/CosyVoice2-0.5B')
|
| 87 |
-
snapshot_download('iic/CosyVoice-300M', local_dir='pretrained_models/CosyVoice-300M')
|
| 88 |
-
snapshot_download('iic/CosyVoice-300M-25Hz', local_dir='pretrained_models/CosyVoice-300M-25Hz')
|
| 89 |
-
snapshot_download('iic/CosyVoice-300M-SFT', local_dir='pretrained_models/CosyVoice-300M-SFT')
|
| 90 |
-
snapshot_download('iic/CosyVoice-300M-Instruct', local_dir='pretrained_models/CosyVoice-300M-Instruct')
|
| 91 |
snapshot_download('iic/CosyVoice-ttsfrd', local_dir='pretrained_models/CosyVoice-ttsfrd')
|
| 92 |
```
|
| 93 |
|
| 94 |
-
|
| 95 |
-
# git模型下载,请确保已安装git lfs
|
| 96 |
-
mkdir -p pretrained_models
|
| 97 |
-
git clone https://www.modelscope.cn/iic/CosyVoice2-0.5B.git pretrained_models/CosyVoice2-0.5B
|
| 98 |
-
git clone https://www.modelscope.cn/iic/CosyVoice-300M.git pretrained_models/CosyVoice-300M
|
| 99 |
-
git clone https://www.modelscope.cn/iic/CosyVoice-300M-25Hz.git pretrained_models/CosyVoice-300M-25Hz
|
| 100 |
-
git clone https://www.modelscope.cn/iic/CosyVoice-300M-SFT.git pretrained_models/CosyVoice-300M-SFT
|
| 101 |
-
git clone https://www.modelscope.cn/iic/CosyVoice-300M-Instruct.git pretrained_models/CosyVoice-300M-Instruct
|
| 102 |
-
git clone https://www.modelscope.cn/iic/CosyVoice-ttsfrd.git pretrained_models/CosyVoice-ttsfrd
|
| 103 |
-
```
|
| 104 |
-
|
| 105 |
-
Optionally, you can unzip `ttsfrd` resouce and install `ttsfrd` package for better text normalization performance.
|
| 106 |
|
| 107 |
-
Notice that this step is not necessary. If you do not install `ttsfrd` package, we will use
|
| 108 |
|
| 109 |
``` sh
|
| 110 |
cd pretrained_models/CosyVoice-ttsfrd/
|
|
@@ -113,98 +141,30 @@ pip install ttsfrd_dependency-0.1-py3-none-any.whl
|
|
| 113 |
pip install ttsfrd-0.4.2-cp310-cp310-linux_x86_64.whl
|
| 114 |
```
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
We strongly recommend using `CosyVoice2-0.5B` for better performance.
|
| 119 |
-
Follow code below for detailed usage of each model.
|
| 120 |
|
| 121 |
``` python
|
| 122 |
import sys
|
| 123 |
sys.path.append('third_party/Matcha-TTS')
|
| 124 |
-
from cosyvoice.cli.cosyvoice import
|
| 125 |
-
from cosyvoice.utils.file_utils import load_wav
|
| 126 |
import torchaudio
|
| 127 |
-
```
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
cosyvoice =
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
# zero_shot usage
|
| 135 |
-
prompt_speech_16k = load_wav('zero_shot_prompt.wav', 16000)
|
| 136 |
-
for i, j in enumerate(cosyvoice.inference_zero_shot('收到好友从远方寄来的生日礼物,那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐,笑容如花儿般绽放。', '希望你以后能够做的比我还好呦。', prompt_speech_16k, stream=False)):
|
| 137 |
torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
for i, j in enumerate(cosyvoice.inference_cross_lingual('在他讲述那个荒诞故事的过程中,他突然[laughter]停下来,因为他自己也被逗笑了[laughter]。', prompt_speech_16k, stream=False)):
|
| 141 |
-
torchaudio.save('fine_grained_control_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 142 |
-
|
| 143 |
-
# instruct usage
|
| 144 |
-
for i, j in enumerate(cosyvoice.inference_instruct2('收到好友从远方寄来的生日礼物,那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐,笑容如花儿般绽放。', '用四川话说这句话', prompt_speech_16k, stream=False)):
|
| 145 |
-
torchaudio.save('instruct_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 146 |
-
```
|
| 147 |
-
|
| 148 |
-
**CosyVoice Usage**
|
| 149 |
-
```python
|
| 150 |
-
cosyvoice = CosyVoice('pretrained_models/CosyVoice-300M-SFT', load_jit=False, load_trt=False, fp16=False)
|
| 151 |
-
# sft usage
|
| 152 |
-
print(cosyvoice.list_available_spks())
|
| 153 |
-
# change stream=True for chunk stream inference
|
| 154 |
-
for i, j in enumerate(cosyvoice.inference_sft('你好,我是通义生成式语音大模型,请问有什么可以帮您的吗?', '中文女', stream=False)):
|
| 155 |
-
torchaudio.save('sft_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 156 |
-
|
| 157 |
-
cosyvoice = CosyVoice('pretrained_models/CosyVoice-300M') # or change to pretrained_models/CosyVoice-300M-25Hz for 25Hz inference
|
| 158 |
-
# zero_shot usage, <|zh|><|en|><|jp|><|yue|><|ko|> for Chinese/English/Japanese/Cantonese/Korean
|
| 159 |
-
prompt_speech_16k = load_wav('zero_shot_prompt.wav', 16000)
|
| 160 |
-
for i, j in enumerate(cosyvoice.inference_zero_shot('收到好友从远方寄来的生日礼物,那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐,笑容如花儿般绽放。', '希望你以后能够做的比我还好呦。', prompt_speech_16k, stream=False)):
|
| 161 |
torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 162 |
-
# cross_lingual usage
|
| 163 |
-
|
| 164 |
-
|
| 165 |
torchaudio.save('cross_lingual_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 166 |
# vc usage
|
| 167 |
-
|
| 168 |
-
source_speech_16k = load_wav('cross_lingual_prompt.wav', 16000)
|
| 169 |
-
for i, j in enumerate(cosyvoice.inference_vc(source_speech_16k, prompt_speech_16k, stream=False)):
|
| 170 |
torchaudio.save('vc_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 171 |
-
|
| 172 |
-
cosyvoice = CosyVoice('pretrained_models/CosyVoice-300M-Instruct')
|
| 173 |
-
# instruct usage, support <laughter></laughter><strong></strong>[laughter][breath]
|
| 174 |
-
for i, j in enumerate(cosyvoice.inference_instruct('在面对挑战时,他展现了非凡的<strong>勇气</strong>与<strong>智慧</strong>。', '中文男', 'Theo \'Crimson\', is a fiery, passionate rebel leader. Fights with fervor for justice, but struggles with impulsiveness.', stream=False)):
|
| 175 |
-
torchaudio.save('instruct_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 176 |
-
```
|
| 177 |
-
|
| 178 |
-
**Start web demo**
|
| 179 |
-
|
| 180 |
-
You can use our web demo page to get familiar with CosyVoice quickly.
|
| 181 |
-
|
| 182 |
-
Please see the demo website for details.
|
| 183 |
-
|
| 184 |
-
``` python
|
| 185 |
-
# change iic/CosyVoice-300M-SFT for sft inference, or iic/CosyVoice-300M-Instruct for instruct inference
|
| 186 |
-
python3 webui.py --port 50000 --model_dir pretrained_models/CosyVoice-300M
|
| 187 |
-
```
|
| 188 |
-
|
| 189 |
-
**Advanced Usage**
|
| 190 |
-
|
| 191 |
-
For advanced user, we have provided train and inference scripts in `examples/libritts/cosyvoice/run.sh`.
|
| 192 |
-
|
| 193 |
-
**Build for deployment**
|
| 194 |
-
|
| 195 |
-
Optionally, if you want service deployment,
|
| 196 |
-
you can run following steps.
|
| 197 |
-
|
| 198 |
-
``` sh
|
| 199 |
-
cd runtime/python
|
| 200 |
-
docker build -t cosyvoice:v1.0 .
|
| 201 |
-
# change iic/CosyVoice-300M to iic/CosyVoice-300M-Instruct if you want to use instruct inference
|
| 202 |
-
# for grpc usage
|
| 203 |
-
docker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c "cd /opt/CosyVoice/CosyVoice/runtime/python/grpc && python3 server.py --port 50000 --max_conc 4 --model_dir iic/CosyVoice-300M && sleep infinity"
|
| 204 |
-
cd grpc && python3 client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
|
| 205 |
-
# for fastapi usage
|
| 206 |
-
docker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c "cd /opt/CosyVoice/CosyVoice/runtime/python/fastapi && python3 server.py --port 50000 --model_dir iic/CosyVoice-300M && sleep infinity"
|
| 207 |
-
cd fastapi && python3 client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
|
| 208 |
```
|
| 209 |
|
| 210 |
## Discussion & Communication
|
|
@@ -223,5 +183,39 @@ You can also scan the QR code to join our official Dingding chat group.
|
|
| 223 |
4. We borrowed a lot of code from [AcademiCodec](https://github.com/yangdongchao/AcademiCodec).
|
| 224 |
5. We borrowed a lot of code from [WeNet](https://github.com/wenet-e2e/wenet).
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
## Disclaimer
|
| 227 |
-
The content provided above is for academic purposes only and is intended to demonstrate technical capabilities. Some examples are sourced from the internet. If any content infringes on your rights, please contact us to request its removal.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- zh
|
| 5 |
+
- en
|
| 6 |
+
- fr
|
| 7 |
+
- es
|
| 8 |
+
- ja
|
| 9 |
+
- ko
|
| 10 |
+
- it
|
| 11 |
+
- ru
|
| 12 |
+
- de
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+

|
| 16 |
|
| 17 |
## 👉🏻 CosyVoice 👈🏻
|
|
|
|
| 18 |
|
| 19 |
+
**Fun-CosyVoice 3.0**: [Demos](https://funaudiollm.github.io/cosyvoice3/); [Paper](https://arxiv.org/abs/2505.17589); [Modelscope](https://www.modelscope.cn/models/FunAudioLLM/Fun-CosyVoice3-0.5B-2512); [Huggingface](https://huggingface.co/FunAudioLLM/Fun-CosyVoice3-0.5B-2512); [CV3-Eval](https://github.com/FunAudioLLM/CV3-Eval)
|
| 20 |
+
|
| 21 |
+
**CosyVoice 2.0**: [Demos](https://funaudiollm.github.io/cosyvoice2/); [Paper](https://arxiv.org/abs/2412.10117); [Modelscope](https://www.modelscope.cn/models/iic/CosyVoice2-0.5B); [HuggingFace](https://huggingface.co/FunAudioLLM/CosyVoice2-0.5B)
|
| 22 |
+
|
| 23 |
+
**CosyVoice 1.0**: [Demos](https://fun-audio-llm.github.io); [Paper](https://funaudiollm.github.io/pdf/CosyVoice_v1.pdf); [Modelscope](https://www.modelscope.cn/models/iic/CosyVoice-300M); [HuggingFace](https://huggingface.co/FunAudioLLM/CosyVoice-300M)
|
| 24 |
|
| 25 |
## Highlight🔥
|
| 26 |
|
| 27 |
+
**Fun-CosyVoice 3.0** is an advanced text-to-speech (TTS) system based on large language models (LLM), surpassing its predecessor (CosyVoice 2.0) in content consistency, speaker similarity, and prosody naturalness. It is designed for zero-shot multilingual speech synthesis in the wild.
|
| 28 |
+
### Key Features
|
| 29 |
+
- **Language Coverage**: Covers 9 common languages (Chinese, English, Japanese, Korean, German, Spanish, French, Italian, Russian), 18+ Chinese dialects/accents (Guangdong, Minnan, Sichuan, Dongbei, Shan3xi, Shan1xi, Shanghai, Tianjin, Shandong, Ningxia, Gansu, etc.) and meanwhile supports both multi-lingual/cross-lingual zero-shot voice cloning.
|
| 30 |
+
- **Content Consistency & Naturalness**: Achieves state-of-the-art performance in content consistency, speaker similarity, and prosody naturalness.
|
| 31 |
+
- **Pronunciation Inpainting**: Supports pronunciation inpainting of Chinese Pinyin and English CMU phonemes, providing more controllability and thus suitable for production use.
|
| 32 |
+
- **Text Normalization**: Supports reading of numbers, special symbols and various text formats without a traditional frontend module.
|
| 33 |
+
- **Bi-Streaming**: Support both text-in streaming and audio-out streaming, and achieves latency as low as 150ms while maintaining high-quality audio output.
|
| 34 |
+
- **Instruct Support**: Supports various instructions such as languages, dialects, emotions, speed, volume, etc.
|
| 35 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
## Roadmap
|
| 38 |
|
| 39 |
+
- [x] 2025/12
|
| 40 |
+
|
| 41 |
+
- [x] release Fun-CosyVoice3-0.5B-2512 base model, rl model and its training/inference script
|
| 42 |
+
- [x] release Fun-CosyVoice3-0.5B modelscope gradio space
|
| 43 |
+
|
| 44 |
+
- [x] 2025/08
|
| 45 |
+
|
| 46 |
+
- [x] Thanks to the contribution from NVIDIA Yuekai Zhang, add triton trtllm runtime support and cosyvoice2 grpo training support
|
| 47 |
+
|
| 48 |
+
- [x] 2025/07
|
| 49 |
+
|
| 50 |
+
- [x] release Fun-CosyVoice 3.0 eval set
|
| 51 |
+
|
| 52 |
+
- [x] 2025/05
|
| 53 |
+
|
| 54 |
+
- [x] add CosyVoice2-0.5B vllm support
|
| 55 |
+
|
| 56 |
- [x] 2024/12
|
| 57 |
|
| 58 |
+
- [x] 25hz CosyVoice2-0.5B released
|
| 59 |
|
| 60 |
- [x] 2024/09
|
| 61 |
|
| 62 |
+
- [x] 25hz CosyVoice-300M base model
|
| 63 |
+
- [x] 25hz CosyVoice-300M voice conversion function
|
| 64 |
|
| 65 |
- [x] 2024/08
|
| 66 |
|
|
|
|
| 73 |
- [x] WeTextProcessing support when ttsfrd is not available
|
| 74 |
- [x] Fastapi server and client
|
| 75 |
|
| 76 |
+
## Evaluation
|
| 77 |
+
|
| 78 |
+
| Model | Open-Source | Model Size | test-zh<br>CER (%) ↓ | test-zh<br>Speaker Similarity (%) ↑ | test-en<br>WER (%) ↓ | test-en<br>Speaker Similarity (%) ↑ | test-hard<br>CER (%) ↓ | test-hard<br>Speaker Similarity (%) ↑ |
|
| 79 |
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
| 80 |
+
| Human | - | - | 1.26 | 75.5 | 2.14 | 73.4 | - | - |
|
| 81 |
+
| Seed-TTS | ❌ | - | 1.12 | 79.6 | 2.25 | 76.2 | 7.59 | 77.6 |
|
| 82 |
+
| MiniMax-Speech | ❌ | - | 0.83 | 78.3 | 1.65 | 69.2 | - | - |
|
| 83 |
+
| F5-TTS | ✅ | 0.3B | 1.52 | 74.1 | 2.00 | 64.7 | 8.67 | 71.3 |
|
| 84 |
+
| Spark TTS | ✅ | 0.5B | 1.2 | 66.0 | 1.98 | 57.3 | - | - |
|
| 85 |
+
| CosyVoice2 | ✅ | 0.5B | 1.45 | 75.7 | 2.57 | 65.9 | 6.83 | 72.4 |
|
| 86 |
+
| FireRedTTS2 | ✅ | 1.5B | 1.14 | 73.2 | 1.95 | 66.5 | - | - |
|
| 87 |
+
| Index-TTS2 | ✅ | 1.5B | 1.03 | 76.5 | 2.23 | 70.6 | 7.12 | 75.5 |
|
| 88 |
+
| VibeVoice-1.5B | ✅ | 1.5B | 1.16 | 74.4 | 3.04 | 68.9 | - | - |
|
| 89 |
+
| VibeVoice-Realtime | ✅ | 0.5B | - | - | 2.05 | 63.3 | - | - |
|
| 90 |
+
| HiggsAudio-v2 | ✅ | 3B | 1.50 | 74.0 | 2.44 | 67.7 | - | - |
|
| 91 |
+
| VoxCPM | ✅ | 0.5B | 0.93 | 77.2 | 1.85 | 72.9 | 8.87 | 73.0 |
|
| 92 |
+
| GLM-TTS | ✅ | 1.5B | 1.03 | 76.1 | - | - | - | - |
|
| 93 |
+
| GLM-TTS RL | ✅ | 1.5B | 0.89 | 76.4 | - | - | - | - |
|
| 94 |
+
| Fun-CosyVoice3-0.5B-2512 | ✅ | 0.5B | 1.21 | 78.0 | 2.24 | 71.8 | 6.71 | 75.8 |
|
| 95 |
+
| Fun-CosyVoice3-0.5B-2512_RL | ✅ | 0.5B | 0.81 | 77.4 | 1.68 | 69.5 | 5.44 | 75.0 |
|
| 96 |
+
|
| 97 |
|
| 98 |
## Install
|
| 99 |
|
| 100 |
+
### Clone and install
|
| 101 |
|
| 102 |
- Clone the repo
|
| 103 |
+
``` sh
|
| 104 |
+
git clone --recursive https://github.com/FunAudioLLM/CosyVoice.git
|
| 105 |
+
# If you failed to clone the submodule due to network failures, please run the following command until success
|
| 106 |
+
cd CosyVoice
|
| 107 |
+
git submodule update --init --recursive
|
| 108 |
+
```
|
| 109 |
|
| 110 |
- Install Conda: please see https://docs.conda.io/en/latest/miniconda.html
|
| 111 |
- Create Conda env:
|
| 112 |
|
| 113 |
+
``` sh
|
| 114 |
+
conda create -n cosyvoice -y python=3.10
|
| 115 |
+
conda activate cosyvoice
|
| 116 |
+
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
+
# If you encounter sox compatibility issues
|
| 119 |
+
# ubuntu
|
| 120 |
+
sudo apt-get install sox libsox-dev
|
| 121 |
+
# centos
|
| 122 |
+
sudo yum install sox sox-devel
|
| 123 |
+
```
|
| 124 |
|
| 125 |
+
### Model download
|
| 126 |
|
| 127 |
``` python
|
| 128 |
+
from huggingface_hub import snapshot_download
|
| 129 |
+
snapshot_download('FunAudioLLM/CosyVoice-300M', local_dir='pretrained_models/CosyVoice-300M')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
snapshot_download('iic/CosyVoice-ttsfrd', local_dir='pretrained_models/CosyVoice-ttsfrd')
|
| 131 |
```
|
| 132 |
|
| 133 |
+
Optionally, you can unzip `ttsfrd` resource and install `ttsfrd` package for better text normalization performance.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
Notice that this step is not necessary. If you do not install `ttsfrd` package, we will use wetext by default.
|
| 136 |
|
| 137 |
``` sh
|
| 138 |
cd pretrained_models/CosyVoice-ttsfrd/
|
|
|
|
| 141 |
pip install ttsfrd-0.4.2-cp310-cp310-linux_x86_64.whl
|
| 142 |
```
|
| 143 |
|
| 144 |
+
### Basic Usage
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
``` python
|
| 147 |
import sys
|
| 148 |
sys.path.append('third_party/Matcha-TTS')
|
| 149 |
+
from cosyvoice.cli.cosyvoice import AutoModel
|
|
|
|
| 150 |
import torchaudio
|
|
|
|
| 151 |
|
| 152 |
+
""" CosyVoice Usage, check https://fun-audio-llm.github.io/ for more details
|
| 153 |
+
"""
|
| 154 |
+
cosyvoice = AutoModel(model_dir='pretrained_models/CosyVoice-300M')
|
| 155 |
+
# en zero_shot usage
|
| 156 |
+
for i, j in enumerate(cosyvoice.inference_zero_shot('CosyVoice is undergoing a comprehensive upgrade, providing more accurate, stable, faster, and better voice generation capabilities.', '希望你以后能够做的比我还好呦。', './asset/zero_shot_prompt.wav')):
|
|
|
|
|
|
|
|
|
|
| 157 |
torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 158 |
+
# zh zero_shot usage
|
| 159 |
+
for i, j in enumerate(cosyvoice.inference_zero_shot('收到好友从远方寄来的生日礼物,那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐,笑容如花儿般绽放。', '希望你以后能够做的比我还好呦。', './asset/zero_shot_prompt.wav')):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 161 |
+
# cross_lingual usage, <|zh|><|en|><|jp|><|yue|><|ko|> for Chinese/English/Japanese/Cantonese/Korean
|
| 162 |
+
for i, j in enumerate(cosyvoice.inference_cross_lingual('<|en|>And then later on, fully acquiring that company. So keeping management in line, interest in line with the asset that\'s coming into the family is a reason why sometimes we don\'t buy the whole thing.',
|
| 163 |
+
'./asset/cross_lingual_prompt.wav')):
|
| 164 |
torchaudio.save('cross_lingual_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
| 165 |
# vc usage
|
| 166 |
+
for i, j in enumerate(cosyvoice.inference_vc('./asset/cross_lingual_prompt.wav', './asset/zero_shot_prompt.wav')):
|
|
|
|
|
|
|
| 167 |
torchaudio.save('vc_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
```
|
| 169 |
|
| 170 |
## Discussion & Communication
|
|
|
|
| 183 |
4. We borrowed a lot of code from [AcademiCodec](https://github.com/yangdongchao/AcademiCodec).
|
| 184 |
5. We borrowed a lot of code from [WeNet](https://github.com/wenet-e2e/wenet).
|
| 185 |
|
| 186 |
+
## Citations
|
| 187 |
+
|
| 188 |
+
``` bibtex
|
| 189 |
+
@article{du2024cosyvoice,
|
| 190 |
+
title={Cosyvoice: A scalable multilingual zero-shot text-to-speech synthesizer based on supervised semantic tokens},
|
| 191 |
+
author={Du, Zhihao and Chen, Qian and Zhang, Shiliang and Hu, Kai and Lu, Heng and Yang, Yexin and Hu, Hangrui and Zheng, Siqi and Gu, Yue and Ma, Ziyang and others},
|
| 192 |
+
journal={arXiv preprint arXiv:2407.05407},
|
| 193 |
+
year={2024}
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
@article{du2024cosyvoice,
|
| 197 |
+
title={Cosyvoice 2: Scalable streaming speech synthesis with large language models},
|
| 198 |
+
author={Du, Zhihao and Wang, Yuxuan and Chen, Qian and Shi, Xian and Lv, Xiang and Zhao, Tianyu and Gao, Zhifu and Yang, Yexin and Gao, Changfeng and Wang, Hui and others},
|
| 199 |
+
journal={arXiv preprint arXiv:2412.10117},
|
| 200 |
+
year={2024}
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
@article{du2025cosyvoice,
|
| 204 |
+
title={CosyVoice 3: Towards In-the-wild Speech Generation via Scaling-up and Post-training},
|
| 205 |
+
author={Du, Zhihao and Gao, Changfeng and Wang, Yuxuan and Yu, Fan and Zhao, Tianyu and Wang, Hao and Lv, Xiang and Wang, Hui and Shi, Xian and An, Keyu and others},
|
| 206 |
+
journal={arXiv preprint arXiv:2505.17589},
|
| 207 |
+
year={2025}
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
@inproceedings{lyu2025build,
|
| 211 |
+
title={Build LLM-Based Zero-Shot Streaming TTS System with Cosyvoice},
|
| 212 |
+
author={Lyu, Xiang and Wang, Yuxuan and Zhao, Tianyu and Wang, Hao and Liu, Huadai and Du, Zhihao},
|
| 213 |
+
booktitle={ICASSP 2025-2025 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
|
| 214 |
+
pages={1--2},
|
| 215 |
+
year={2025},
|
| 216 |
+
organization={IEEE}
|
| 217 |
+
}
|
| 218 |
+
```
|
| 219 |
+
|
| 220 |
## Disclaimer
|
| 221 |
+
The content provided above is for academic purposes only and is intended to demonstrate technical capabilities. Some examples are sourced from the internet. If any content infringes on your rights, please contact us to request its removal.
|