{"id":17454084,"url":"https://github.com/funaudiollm/cosyvoice","last_synced_at":"2025-10-20T03:34:21.509Z","repository":{"id":246935196,"uuid":"823430322","full_name":"FunAudioLLM/CosyVoice","owner":"FunAudioLLM","description":"Multi-lingual large voice generation model, providing inference, training and deployment full-stack ability.","archived":false,"fork":false,"pushed_at":"2025-04-30T01:41:50.000Z","size":1563,"stargazers_count":13471,"open_issues_count":691,"forks_count":1363,"subscribers_count":95,"default_branch":"main","last_synced_at":"2025-04-30T02:38:14.826Z","etag":null,"topics":["audio-generation","cantonese","chatbot","chatgpt","chinese","cosyvoice","cross-lingual","english","fine-grained","fine-tuning","gpt-4o","japanese","korean","multi-lingual","natural-language-generation","python","text-to-speech","tts","voice-cloning"],"latest_commit_sha":null,"homepage":"https://funaudiollm.github.io/cosyvoice2","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FunAudioLLM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-03T02:59:22.000Z","updated_at":"2025-04-30T02:11:19.000Z","dependencies_parsed_at":"2024-08-19T03:23:27.104Z","dependency_job_id":"886911ec-b49c-41b6-8104-4e704f3cd182","html_url":"https://github.com/FunAudioLLM/CosyVoice","commit_stats":{"total_commits":138,"total_committers":19,"mean_commits":"7.2631578947368425","dds":0.4782608695652174,"last_synced_commit":"dfcd6d0a64918342582abc588af9e86eb404d05c"},"previous_names":["funaudiollm/cosyvoice"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FunAudioLLM%2FCosyVoice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FunAudioLLM%2FCosyVoice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FunAudioLLM%2FCosyVoice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FunAudioLLM%2FCosyVoice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FunAudioLLM","download_url":"https://codeload.github.com/FunAudioLLM/CosyVoice/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252843597,"owners_count":21812905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio-generation","cantonese","chatbot","chatgpt","chinese","cosyvoice","cross-lingual","english","fine-grained","fine-tuning","gpt-4o","japanese","korean","multi-lingual","natural-language-generation","python","text-to-speech","tts","voice-cloning"],"created_at":"2024-10-18T01:04:11.563Z","updated_at":"2025-10-20T03:34:21.503Z","avatar_url":"https://github.com/FunAudioLLM.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![SVG Banners](https://svg-banners.vercel.app/api?type=origin\u0026text1=CosyVoice🤠\u0026text2=Text-to-Speech%20💖%20Large%20Language%20Model\u0026width=800\u0026height=210)](https://github.com/Akshay090/svg-banners)\n\n## 👉🏻 CosyVoice 👈🏻\n\n**CosyVoice 3.0**: [Demos](https://funaudiollm.github.io/cosyvoice3/); [Paper](https://arxiv.org/abs/2505.17589); [CV3-Eval](https://github.com/FunAudioLLM/CV3-Eval)\n\n**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)\n\n**CosyVoice 1.0**: [Demos](https://fun-audio-llm.github.io); [Paper](https://funaudiollm.github.io/pdf/CosyVoice_v1.pdf); [Modelscope](https://www.modelscope.cn/studios/iic/CosyVoice-300M)\n\n## Highlight🔥\n\n**CosyVoice 2.0** has been released! Compared to version 1.0, the new version offers more accurate, more stable, faster, and better speech generation capabilities.\n### Multilingual\n- **Supported Language**: Chinese, English, Japanese, Korean, Chinese dialects (Cantonese, Sichuanese, Shanghainese, Tianjinese, Wuhanese, etc.)\n- **Crosslingual \u0026 Mixlingual**：Support zero-shot voice cloning for cross-lingual and code-switching scenarios.\n### Ultra-Low Latency\n- **Bidirectional Streaming Support**: CosyVoice 2.0 integrates offline and streaming modeling technologies.\n- **Rapid First Packet Synthesis**: Achieves latency as low as 150ms while maintaining high-quality audio output.\n### High Accuracy\n- **Improved Pronunciation**: Reduces pronunciation errors by 30% to 50% compared to CosyVoice 1.0.\n- **Benchmark Achievements**: Attains the lowest character error rate on the hard test set of the Seed-TTS evaluation set.\n### Strong Stability\n- **Consistency in Timbre**: Ensures reliable voice consistency for zero-shot and cross-language speech synthesis.\n- **Cross-language Synthesis**: Marked improvements compared to version 1.0.\n### Natural Experience\n- **Enhanced Prosody and Sound Quality**: Improved alignment of synthesized audio, raising MOS evaluation scores from 5.4 to 5.53.\n- **Emotional and Dialectal Flexibility**: Now supports more granular emotional controls and accent adjustments.\n\n## Roadmap\n\n- [x] 2025/08\n\n    - [x] Thanks to the contribution from NVIDIA Yuekai Zhang, add triton trtllm runtime support and cosyvoice2 grpo training support\n\n- [x] 2025/07\n\n    - [x] release cosyvoice 3.0 eval set\n\n- [x] 2025/05\n\n    - [x] add cosyvoice 2.0 vllm support\n\n- [x] 2024/12\n\n    - [x] 25hz cosyvoice 2.0 released\n\n- [x] 2024/09\n\n    - [x] 25hz cosyvoice base model\n    - [x] 25hz cosyvoice voice conversion model\n\n- [x] 2024/08\n\n    - [x] Repetition Aware Sampling(RAS) inference for llm stability\n    - [x] Streaming inference mode support, including kv cache and sdpa for rtf optimization\n\n- [x] 2024/07\n\n    - [x] Flow matching training support\n    - [x] WeTextProcessing support when ttsfrd is not available\n    - [x] Fastapi server and client\n\n\n## Install\n\n### Clone and install\n\n- Clone the repo\n    ``` sh\n    git clone --recursive https://github.com/FunAudioLLM/CosyVoice.git\n    # If you failed to clone the submodule due to network failures, please run the following command until success\n    cd CosyVoice\n    git submodule update --init --recursive\n    ```\n\n- Install Conda: please see https://docs.conda.io/en/latest/miniconda.html\n- Create Conda env:\n\n    ``` sh\n    conda create -n cosyvoice -y python=3.10\n    conda activate cosyvoice\n    pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com\n\n    # If you encounter sox compatibility issues\n    # ubuntu\n    sudo apt-get install sox libsox-dev\n    # centos\n    sudo yum install sox sox-devel\n    ```\n\n### Model download\n\nWe strongly recommend that you download our pretrained `CosyVoice2-0.5B` `CosyVoice-300M` `CosyVoice-300M-SFT` `CosyVoice-300M-Instruct` model and `CosyVoice-ttsfrd` resource.\n\n``` python\n# SDK模型下载\nfrom modelscope import snapshot_download\nsnapshot_download('iic/CosyVoice2-0.5B', local_dir='pretrained_models/CosyVoice2-0.5B')\nsnapshot_download('iic/CosyVoice-300M', local_dir='pretrained_models/CosyVoice-300M')\nsnapshot_download('iic/CosyVoice-300M-SFT', local_dir='pretrained_models/CosyVoice-300M-SFT')\nsnapshot_download('iic/CosyVoice-300M-Instruct', local_dir='pretrained_models/CosyVoice-300M-Instruct')\nsnapshot_download('iic/CosyVoice-ttsfrd', local_dir='pretrained_models/CosyVoice-ttsfrd')\n```\n\n``` sh\n# git模型下载，请确保已安装git lfs\nmkdir -p pretrained_models\ngit clone https://www.modelscope.cn/iic/CosyVoice2-0.5B.git pretrained_models/CosyVoice2-0.5B\ngit clone https://www.modelscope.cn/iic/CosyVoice-300M.git pretrained_models/CosyVoice-300M\ngit clone https://www.modelscope.cn/iic/CosyVoice-300M-SFT.git pretrained_models/CosyVoice-300M-SFT\ngit clone https://www.modelscope.cn/iic/CosyVoice-300M-Instruct.git pretrained_models/CosyVoice-300M-Instruct\ngit clone https://www.modelscope.cn/iic/CosyVoice-ttsfrd.git pretrained_models/CosyVoice-ttsfrd\n```\n\nOptionally, you can unzip `ttsfrd` resource and install `ttsfrd` package for better text normalization performance.\n\nNotice that this step is not necessary. If you do not install `ttsfrd` package, we will use wetext by default.\n\n``` sh\ncd pretrained_models/CosyVoice-ttsfrd/\nunzip resource.zip -d .\npip install ttsfrd_dependency-0.1-py3-none-any.whl\npip install ttsfrd-0.4.2-cp310-cp310-linux_x86_64.whl\n```\n\n### Basic Usage\n\nWe strongly recommend using `CosyVoice2-0.5B` for better performance.\nFollow the code below for detailed usage of each model.\n\n``` python\nimport sys\nsys.path.append('third_party/Matcha-TTS')\nfrom cosyvoice.cli.cosyvoice import CosyVoice, CosyVoice2\nfrom cosyvoice.utils.file_utils import load_wav\nimport torchaudio\n```\n\n#### CosyVoice2 Usage\n```python\ncosyvoice = CosyVoice2('pretrained_models/CosyVoice2-0.5B', load_jit=False, load_trt=False, load_vllm=False, fp16=False)\n\n# NOTE if you want to reproduce the results on https://funaudiollm.github.io/cosyvoice2, please add text_frontend=False during inference\n# zero_shot usage\nprompt_speech_16k = load_wav('./asset/zero_shot_prompt.wav', 16000)\nfor i, j in enumerate(cosyvoice.inference_zero_shot('收到好友从远方寄来的生日礼物，那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐，笑容如花儿般绽放。', '希望你以后能够做的比我还好呦。', prompt_speech_16k, stream=False)):\n    torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)\n\n# save zero_shot spk for future usage\nassert cosyvoice.add_zero_shot_spk('希望你以后能够做的比我还好呦。', prompt_speech_16k, 'my_zero_shot_spk') is True\nfor i, j in enumerate(cosyvoice.inference_zero_shot('收到好友从远方寄来的生日礼物，那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐，笑容如花儿般绽放。', '', '', zero_shot_spk_id='my_zero_shot_spk', stream=False)):\n    torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)\ncosyvoice.save_spkinfo()\n\n# fine grained control, for supported control, check cosyvoice/tokenizer/tokenizer.py#L248\nfor i, j in enumerate(cosyvoice.inference_cross_lingual('在他讲述那个荒诞故事的过程中，他突然[laughter]停下来，因为他自己也被逗笑了[laughter]。', prompt_speech_16k, stream=False)):\n    torchaudio.save('fine_grained_control_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)\n\n# instruct usage\nfor i, j in enumerate(cosyvoice.inference_instruct2('收到好友从远方寄来的生日礼物，那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐，笑容如花儿般绽放。', '用四川话说这句话', prompt_speech_16k, stream=False)):\n    torchaudio.save('instruct_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)\n\n# bistream usage, you can use generator as input, this is useful when using text llm model as input\n# NOTE you should still have some basic sentence split logic because llm can not handle arbitrary sentence length\ndef text_generator():\n    yield '收到好友从远方寄来的生日礼物，'\n    yield '那份意外的惊喜与深深的祝福'\n    yield '让我心中充满了甜蜜的快乐，'\n    yield '笑容如花儿般绽放。'\nfor i, j in enumerate(cosyvoice.inference_zero_shot(text_generator(), '希望你以后能够做的比我还好呦。', prompt_speech_16k, stream=False)):\n    torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)\n```\n\n#### CosyVoice2 vllm Usage\nIf you want to use vllm for inference, please install `vllm==v0.9.0`. Older vllm version do not support CosyVoice2 inference.\n\nNotice that `vllm==v0.9.0` has a lot of specific requirements, for example `torch==2.7.0`. You can create a new env to in case your hardward do not support vllm and old env is corrupted.\n\n``` sh\nconda create -n cosyvoice_vllm --clone cosyvoice\nconda activate cosyvoice_vllm\npip install vllm==v0.9.0 transformers==4.51.3 -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com\npython vllm_example.py\n```\n\n#### CosyVoice Usage\n```python\ncosyvoice = CosyVoice('pretrained_models/CosyVoice-300M-SFT', load_jit=False, load_trt=False, fp16=False)\n# sft usage\nprint(cosyvoice.list_available_spks())\n# change stream=True for chunk stream inference\nfor i, j in enumerate(cosyvoice.inference_sft('你好，我是通义生成式语音大模型，请问有什么可以帮您的吗？', '中文女', stream=False)):\n    torchaudio.save('sft_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)\n\ncosyvoice = CosyVoice('pretrained_models/CosyVoice-300M')\n# zero_shot usage, \u003c|zh|\u003e\u003c|en|\u003e\u003c|jp|\u003e\u003c|yue|\u003e\u003c|ko|\u003e for Chinese/English/Japanese/Cantonese/Korean\nprompt_speech_16k = load_wav('./asset/zero_shot_prompt.wav', 16000)\nfor i, j in enumerate(cosyvoice.inference_zero_shot('收到好友从远方寄来的生日礼物，那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐，笑容如花儿般绽放。', '希望你以后能够做的比我还好呦。', prompt_speech_16k, stream=False)):\n    torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)\n# cross_lingual usage\nprompt_speech_16k = load_wav('./asset/cross_lingual_prompt.wav', 16000)\nfor i, j in enumerate(cosyvoice.inference_cross_lingual('\u003c|en|\u003eAnd 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, stream=False)):\n    torchaudio.save('cross_lingual_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)\n# vc usage\nprompt_speech_16k = load_wav('./asset/zero_shot_prompt.wav', 16000)\nsource_speech_16k = load_wav('./asset/cross_lingual_prompt.wav', 16000)\nfor i, j in enumerate(cosyvoice.inference_vc(source_speech_16k, prompt_speech_16k, stream=False)):\n    torchaudio.save('vc_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)\n\ncosyvoice = CosyVoice('pretrained_models/CosyVoice-300M-Instruct')\n# instruct usage, support \u003claughter\u003e\u003c/laughter\u003e\u003cstrong\u003e\u003c/strong\u003e[laughter][breath]\nfor i, j in enumerate(cosyvoice.inference_instruct('在面对挑战时，他展现了非凡的\u003cstrong\u003e勇气\u003c/strong\u003e与\u003cstrong\u003e智慧\u003c/strong\u003e。', '中文男', 'Theo \\'Crimson\\', is a fiery, passionate rebel leader. Fights with fervor for justice, but struggles with impulsiveness.', stream=False)):\n    torchaudio.save('instruct_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)\n```\n\n#### Start web demo\n\nYou can use our web demo page to get familiar with CosyVoice quickly.\n\nPlease see the demo website for details.\n\n``` python\n# change iic/CosyVoice-300M-SFT for sft inference, or iic/CosyVoice-300M-Instruct for instruct inference\npython3 webui.py --port 50000 --model_dir pretrained_models/CosyVoice-300M\n```\n\n#### Advanced Usage\n\nFor advanced users, we have provided training and inference scripts in `examples/libritts/cosyvoice/run.sh`.\n\n#### Build for deployment\n\nOptionally, if you want service deployment,\nYou can run the following steps.\n\n``` sh\ncd runtime/python\ndocker build -t cosyvoice:v1.0 .\n# change iic/CosyVoice-300M to iic/CosyVoice-300M-Instruct if you want to use instruct inference\n# for grpc usage\ndocker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c \"cd /opt/CosyVoice/CosyVoice/runtime/python/grpc \u0026\u0026 python3 server.py --port 50000 --max_conc 4 --model_dir iic/CosyVoice-300M \u0026\u0026 sleep infinity\"\ncd grpc \u0026\u0026 python3 client.py --port 50000 --mode \u003csft|zero_shot|cross_lingual|instruct\u003e\n# for fastapi usage\ndocker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c \"cd /opt/CosyVoice/CosyVoice/runtime/python/fastapi \u0026\u0026 python3 server.py --port 50000 --model_dir iic/CosyVoice-300M \u0026\u0026 sleep infinity\"\ncd fastapi \u0026\u0026 python3 client.py --port 50000 --mode \u003csft|zero_shot|cross_lingual|instruct\u003e\n```\n\n#### Using Nvidia TensorRT-LLM for deployment\n\nUsing TensorRT-LLM to accelerate cosyvoice2 llm could give 4x acceleration comparing with huggingface transformers implementation.\nTo quick start:\n\n``` sh\ncd runtime/triton_trtllm\ndocker compose up -d\n```\nFor more details, you could check [here](https://github.com/FunAudioLLM/CosyVoice/tree/main/runtime/triton_trtllm)\n\n## Discussion \u0026 Communication\n\nYou can directly discuss on [Github Issues](https://github.com/FunAudioLLM/CosyVoice/issues).\n\nYou can also scan the QR code to join our official Dingding chat group.\n\n\u003cimg src=\"./asset/dingding.png\" width=\"250px\"\u003e\n\n## Acknowledge\n\n1. We borrowed a lot of code from [FunASR](https://github.com/modelscope/FunASR).\n2. We borrowed a lot of code from [FunCodec](https://github.com/modelscope/FunCodec).\n3. We borrowed a lot of code from [Matcha-TTS](https://github.com/shivammehta25/Matcha-TTS).\n4. We borrowed a lot of code from [AcademiCodec](https://github.com/yangdongchao/AcademiCodec).\n5. We borrowed a lot of code from [WeNet](https://github.com/wenet-e2e/wenet).\n\n## Citations\n\n``` bibtex\n@article{du2024cosyvoice,\n  title={Cosyvoice: A scalable multilingual zero-shot text-to-speech synthesizer based on supervised semantic tokens},\n  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},\n  journal={arXiv preprint arXiv:2407.05407},\n  year={2024}\n}\n\n@article{du2024cosyvoice,\n  title={Cosyvoice 2: Scalable streaming speech synthesis with large language models},\n  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},\n  journal={arXiv preprint arXiv:2412.10117},\n  year={2024}\n}\n\n@article{du2025cosyvoice,\n  title={CosyVoice 3: Towards In-the-wild Speech Generation via Scaling-up and Post-training},\n  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},\n  journal={arXiv preprint arXiv:2505.17589},\n  year={2025}\n}\n\n@inproceedings{lyu2025build,\n  title={Build LLM-Based Zero-Shot Streaming TTS System with Cosyvoice},\n  author={Lyu, Xiang and Wang, Yuxuan and Zhao, Tianyu and Wang, Hao and Liu, Huadai and Du, Zhihao},\n  booktitle={ICASSP 2025-2025 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},\n  pages={1--2},\n  year={2025},\n  organization={IEEE}\n}\n```\n\n## Disclaimer\nThe 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunaudiollm%2Fcosyvoice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunaudiollm%2Fcosyvoice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunaudiollm%2Fcosyvoice/lists"}