kevinwang676 commited on
Commit
e8a3d79
1 Parent(s): 13fa4f9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -159
README.md CHANGED
@@ -1,159 +1,13 @@
1
- # CosyVoice
2
- ## 👉🏻 [CosyVoice Demos](https://fun-audio-llm.github.io/) 👈🏻
3
- [[CosyVoice Paper](https://fun-audio-llm.github.io/pdf/CosyVoice_v1.pdf)][[CosyVoice Studio](https://www.modelscope.cn/studios/iic/CosyVoice-300M)][[CosyVoice Code](https://github.com/FunAudioLLM/CosyVoice)]
4
-
5
- For `SenseVoice`, visit [SenseVoice repo](https://github.com/FunAudioLLM/SenseVoice) and [SenseVoice space](https://www.modelscope.cn/studios/iic/SenseVoice).
6
-
7
- ## Install
8
-
9
- **Clone and install**
10
-
11
- - Clone the repo
12
- ``` sh
13
- git clone --recursive https://github.com/FunAudioLLM/CosyVoice.git
14
- # If you failed to clone submodule due to network failures, please run following command until success
15
- cd CosyVoice
16
- git submodule update --init --recursive
17
- ```
18
-
19
- - Install Conda: please see https://docs.conda.io/en/latest/miniconda.html
20
- - Create Conda env:
21
-
22
- ``` sh
23
- conda create -n cosyvoice python=3.8
24
- conda activate cosyvoice
25
- # pynini is required by WeTextProcessing, use conda to install it as it can be executed on all platform.
26
- conda install -y -c conda-forge pynini==2.1.5
27
- pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
28
-
29
- # If you encounter sox compatibility issues
30
- # ubuntu
31
- sudo apt-get install sox libsox-dev
32
- # centos
33
- sudo yum install sox sox-devel
34
- ```
35
-
36
- **Model download**
37
-
38
- We strongly recommend that you download our pretrained `CosyVoice-300M` `CosyVoice-300M-SFT` `CosyVoice-300M-Instruct` model and `CosyVoice-ttsfrd` resource.
39
-
40
- If you are expert in this field, and you are only interested in training your own CosyVoice model from scratch, you can skip this step.
41
-
42
- ``` python
43
- # SDK模型下载
44
- from modelscope import snapshot_download
45
- snapshot_download('iic/CosyVoice-300M', local_dir='pretrained_models/CosyVoice-300M')
46
- snapshot_download('iic/CosyVoice-300M-SFT', local_dir='pretrained_models/CosyVoice-300M-SFT')
47
- snapshot_download('iic/CosyVoice-300M-Instruct', local_dir='pretrained_models/CosyVoice-300M-Instruct')
48
- snapshot_download('iic/CosyVoice-ttsfrd', local_dir='pretrained_models/CosyVoice-ttsfrd')
49
- ```
50
-
51
- ``` sh
52
- # git模型下载,请确保已安装git lfs
53
- mkdir -p pretrained_models
54
- git clone https://www.modelscope.cn/iic/CosyVoice-300M.git pretrained_models/CosyVoice-300M
55
- git clone https://www.modelscope.cn/iic/CosyVoice-300M-SFT.git pretrained_models/CosyVoice-300M-SFT
56
- git clone https://www.modelscope.cn/iic/CosyVoice-300M-Instruct.git pretrained_models/CosyVoice-300M-Instruct
57
- git clone https://www.modelscope.cn/iic/CosyVoice-ttsfrd.git pretrained_models/CosyVoice-ttsfrd
58
- ```
59
-
60
- Optionaly, you can unzip `ttsfrd` resouce and install `ttsfrd` package for better text normalization performance.
61
-
62
- Notice that this step is not necessary. If you do not install `ttsfrd` package, we will use WeTextProcessing by default.
63
-
64
- ``` sh
65
- cd pretrained_models/CosyVoice-ttsfrd/
66
- unzip resource.zip -d .
67
- pip install ttsfrd-0.3.6-cp38-cp38-linux_x86_64.whl
68
- ```
69
-
70
- **Basic Usage**
71
-
72
- For zero_shot/cross_lingual inference, please use `CosyVoice-300M` model.
73
- For sft inference, please use `CosyVoice-300M-SFT` model.
74
- For instruct inference, please use `CosyVoice-300M-Instruct` model.
75
- First, add `third_party/Matcha-TTS` to your `PYTHONPATH`.
76
-
77
- ``` sh
78
- export PYTHONPATH=third_party/Matcha-TTS
79
- ```
80
-
81
- ``` python
82
- from cosyvoice.cli.cosyvoice import CosyVoice
83
- from cosyvoice.utils.file_utils import load_wav
84
- import torchaudio
85
-
86
- cosyvoice = CosyVoice('pretrained_models/CosyVoice-300M-SFT')
87
- # sft usage
88
- print(cosyvoice.list_avaliable_spks())
89
- output = cosyvoice.inference_sft('你好,我是通义生成式语音大模型,请问有什么可以帮您的吗?', '中文女')
90
- torchaudio.save('sft.wav', output['tts_speech'], 22050)
91
-
92
- cosyvoice = CosyVoice('pretrained_models/CosyVoice-300M')
93
- # zero_shot usage, <|zh|><|en|><|jp|><|yue|><|ko|> for Chinese/English/Japanese/Cantonese/Korean
94
- prompt_speech_16k = load_wav('zero_shot_prompt.wav', 16000)
95
- output = cosyvoice.inference_zero_shot('收到好友从远方寄来的生日礼物,那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐,笑容如花儿般绽放。', '希望你以后能够做的比我还好呦。', prompt_speech_16k)
96
- torchaudio.save('zero_shot.wav', output['tts_speech'], 22050)
97
- # cross_lingual usage
98
- prompt_speech_16k = load_wav('cross_lingual_prompt.wav', 16000)
99
- output = 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.', prompt_speech_16k)
100
- torchaudio.save('cross_lingual.wav', output['tts_speech'], 22050)
101
-
102
- cosyvoice = CosyVoice('pretrained_models/CosyVoice-300M-Instruct')
103
- # instruct usage, support <laughter></laughter><strong></strong>[laughter][breath]
104
- output = cosyvoice.inference_instruct('在面对挑战时,他展现了非凡的<strong>勇气</strong>与<strong>智慧</strong>。', '中文男', 'Theo \'Crimson\', is a fiery, passionate rebel leader. Fights with fervor for justice, but struggles with impulsiveness.')
105
- torchaudio.save('instruct.wav', output['tts_speech'], 22050)
106
- ```
107
-
108
- **Start web demo**
109
-
110
- You can use our web demo page to get familiar with CosyVoice quickly.
111
- We support sft/zero_shot/cross_lingual/instruct inference in web demo.
112
-
113
- Please see the demo website for details.
114
-
115
- ``` python
116
- # change iic/CosyVoice-300M-SFT for sft inference, or iic/CosyVoice-300M-Instruct for instruct inference
117
- python3 webui.py --port 50000 --model_dir pretrained_models/CosyVoice-300M
118
- ```
119
-
120
- **Advanced Usage**
121
-
122
- For advanced user, we have provided train and inference scripts in `examples/libritts/cosyvoice/run.sh`.
123
- You can get familiar with CosyVoice following this recipie.
124
-
125
- **Build for deployment**
126
-
127
- Optionally, if you want to use grpc for service deployment,
128
- you can run following steps. Otherwise, you can just ignore this step.
129
-
130
- ``` sh
131
- cd runtime/python
132
- docker build -t cosyvoice:v1.0 .
133
- # change iic/CosyVoice-300M to iic/CosyVoice-300M-Instruct if you want to use instruct inference
134
- # for grpc usage
135
- 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"
136
- python3 grpc/client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
137
- # for fastapi usage
138
- docker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c "cd /opt/CosyVoice/CosyVoice/runtime/python/fastapi && MODEL_DIR=iic/CosyVoice-300M fastapi dev --port 50000 server.py && sleep infinity"
139
- python3 fastapi/client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
140
- ```
141
-
142
- ## Discussion & Communication
143
-
144
- You can directly discuss on [Github Issues](https://github.com/FunAudioLLM/CosyVoice/issues).
145
-
146
- You can also scan the QR code to join our official Dingding chat group.
147
-
148
- <img src="./asset/dingding.png" width="250px">
149
-
150
- ## Acknowledge
151
-
152
- 1. We borrowed a lot of code from [FunASR](https://github.com/modelscope/FunASR).
153
- 2. We borrowed a lot of code from [FunCodec](https://github.com/modelscope/FunCodec).
154
- 3. We borrowed a lot of code from [Matcha-TTS](https://github.com/shivammehta25/Matcha-TTS).
155
- 4. We borrowed a lot of code from [AcademiCodec](https://github.com/yangdongchao/AcademiCodec).
156
- 5. We borrowed a lot of code from [WeNet](https://github.com/wenet-e2e/wenet).
157
-
158
- ## Disclaimer
159
- 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
+ title: CosyVoice Instruct
3
+ emoji: 🔥
4
+ colorFrom: green
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: 4.38.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference