Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +31 -0
- VoxCPM/.github/workflows/publish-to-pypi.yml +54 -0
- VoxCPM/.gitignore +3 -0
- VoxCPM/LICENSE +201 -0
- VoxCPM/README.md +353 -0
- VoxCPM/app.py +274 -0
- VoxCPM/assets/modelbest_logo.png +0 -0
- VoxCPM/assets/thuhcsi_logo.png +0 -0
- VoxCPM/assets/voxcpm_logo.png +0 -0
- VoxCPM/assets/voxcpm_model.png +3 -0
- VoxCPM/assets/wechat.png +0 -0
- VoxCPM/ckpts/.gitattributes +36 -0
- VoxCPM/ckpts/README.md +238 -0
- VoxCPM/ckpts/assets/modelbest_logo.png +0 -0
- VoxCPM/ckpts/assets/thuhcsi_logo.png +0 -0
- VoxCPM/ckpts/assets/voxcpm_logo.png +0 -0
- VoxCPM/ckpts/assets/voxcpm_model.png +3 -0
- VoxCPM/ckpts/audiovae.pth +3 -0
- VoxCPM/ckpts/config.json +52 -0
- VoxCPM/ckpts/pytorch_model.bin +3 -0
- VoxCPM/ckpts/special_tokens_map.json +81 -0
- VoxCPM/ckpts/tokenizer.json +0 -0
- VoxCPM/ckpts/tokenizer_config.json +212 -0
- VoxCPM/conf/voxcpm/experiments/README.md +60 -0
- VoxCPM/conf/voxcpm/experiments/exp_01_dit_only_scale05.yaml +33 -0
- VoxCPM/conf/voxcpm/experiments/exp_02_dit_only_scale10.yaml +33 -0
- VoxCPM/conf/voxcpm/experiments/exp_03_dit_only_scale20.yaml +33 -0
- VoxCPM/conf/voxcpm/experiments/exp_04_lm_only_scale05.yaml +33 -0
- VoxCPM/conf/voxcpm/experiments/exp_05_lm_only_scale025.yaml +33 -0
- VoxCPM/conf/voxcpm/experiments/exp_06_both_scale05.yaml +33 -0
- VoxCPM/conf/voxcpm/experiments/exp_07_both_scale025.yaml +33 -0
- VoxCPM/conf/voxcpm/experiments/exp_08_dit_only_small_r.yaml +33 -0
- VoxCPM/conf/voxcpm/experiments/exp_09_dit_only_large_r.yaml +33 -0
- VoxCPM/conf/voxcpm/experiments/exp_10_dit_only_more_modules.yaml +33 -0
- VoxCPM/conf/voxcpm/voxcpm_finetune_example.yaml +23 -0
- VoxCPM/conf/voxcpm/voxcpm_finetune_lora.yaml +31 -0
- VoxCPM/datasets.zip +3 -0
- VoxCPM/docs/finetune.md +260 -0
- VoxCPM/examples/example.wav +3 -0
- VoxCPM/inference.py +67 -0
- VoxCPM/inference_lora.py +91 -0
- VoxCPM/prompt_sample.wav +3 -0
- VoxCPM/pyproject.toml +95 -0
- VoxCPM/requirements.txt +2 -0
- VoxCPM/scripts/test_voxcpm_ft_infer.py +165 -0
- VoxCPM/scripts/test_voxcpm_lora_infer.py +232 -0
- VoxCPM/scripts/train_voxcpm_finetune.py +287 -0
- VoxCPM/src/voxcpm.egg-info/PKG-INFO +403 -0
- VoxCPM/src/voxcpm.egg-info/SOURCES.txt +48 -0
- VoxCPM/src/voxcpm.egg-info/dependency_links.txt +1 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,34 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
VoxCPM/assets/voxcpm_model.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
VoxCPM/ckpts/assets/voxcpm_model.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
VoxCPM/examples/example.wav filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
VoxCPM/prompt_sample.wav filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
eval/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/asr_example_hotword.wav filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
eval/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/example/asr_example.wav filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
eval/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/fig/res.png filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
eval/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/fig/seaco.png filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
eval/thirdparty/UniSpeech/UniSpeech-SAT/UniSpeech_SAT_SUPERB_Results.png filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
eval/thirdparty/UniSpeech/WavLM/WavLM_ASR.PNG filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
eval/thirdparty/UniSpeech/WavLM/WavLM_SUPERB_Leaderboard.png filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
eval/thirdparty/UniSpeech/WavLM/WavLM_SUPERB_Results.png filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
eval/thirdparty/UniSpeech/downstreams/speaker_verification/vox1_data/David_Faustino/hn8GyCJIfLM_0000012.wav filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
eval/thirdparty/UniSpeech/downstreams/speaker_verification/vox1_data/David_Faustino/xTOk1Jz-F_g_0000015.wav filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
eval/thirdparty/UniSpeech/downstreams/speaker_verification/vox1_data/Josh_Gad/HXUqYaOwrxA_0000015.wav filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
eval/thirdparty/UniSpeech/downstreams/speaker_verification/vox1_data/Josh_Gad/RFyw7V3SOnQ_0000001.wav filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
eval/thirdparty/UniSpeech/downstreams/speaker_verification/vox1_data/Lea_Thompson/HladKGyKTLM_0000006.wav filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
eval/thirdparty/UniSpeech/downstreams/speaker_verification/vox1_data/Lea_Thompson/mHTAr5dlAgc_0000004.wav filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
eval/thirdparty/UniSpeech/downstreams/speaker_verification/vox1_data/Zulay_Henao/WbB8m9-wlIQ_0000001.wav filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
eval/thirdparty/UniSpeech/downstreams/speaker_verification/vox1_data/Zulay_Henao/gFfcgOVmiO0_0000002.wav filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
eval/thirdparty/UniSpeech/src/examples/speaker_verification/vox1_data/David_Faustino/hn8GyCJIfLM_0000012.wav filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
eval/thirdparty/UniSpeech/src/examples/speaker_verification/vox1_data/David_Faustino/xTOk1Jz-F_g_0000015.wav filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
eval/thirdparty/UniSpeech/src/examples/speaker_verification/vox1_data/Josh_Gad/HXUqYaOwrxA_0000015.wav filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
eval/thirdparty/UniSpeech/src/examples/speaker_verification/vox1_data/Josh_Gad/RFyw7V3SOnQ_0000001.wav filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
eval/thirdparty/UniSpeech/src/examples/speaker_verification/vox1_data/Lea_Thompson/HladKGyKTLM_0000006.wav filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
eval/thirdparty/UniSpeech/src/examples/speaker_verification/vox1_data/Lea_Thompson/mHTAr5dlAgc_0000004.wav filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
eval/thirdparty/UniSpeech/src/examples/speaker_verification/vox1_data/Zulay_Henao/WbB8m9-wlIQ_0000001.wav filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
eval/thirdparty/UniSpeech/src/examples/speaker_verification/vox1_data/Zulay_Henao/gFfcgOVmiO0_0000002.wav filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
eval/thirdparty/UniSpeech/src/fairseq/data/data_utils_fast.cpython-36m-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
eval/thirdparty/UniSpeech/src/fairseq/data/data_utils_fast.cpython-37m-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
实验三:基于VoxCPM的音色克隆(实验指导).pdf filter=lfs diff=lfs merge=lfs -text
|
VoxCPM/.github/workflows/publish-to-pypi.yml
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Publish Python 🐍 distribution 📦 to PyPI
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
release:
|
| 5 |
+
types: [created]
|
| 6 |
+
|
| 7 |
+
jobs:
|
| 8 |
+
build:
|
| 9 |
+
name: Build distribution 📦
|
| 10 |
+
runs-on: ubuntu-latest
|
| 11 |
+
|
| 12 |
+
steps:
|
| 13 |
+
- uses: actions/checkout@v4
|
| 14 |
+
with:
|
| 15 |
+
persist-credentials: false
|
| 16 |
+
- name: Set up Python
|
| 17 |
+
uses: actions/setup-python@v5
|
| 18 |
+
with:
|
| 19 |
+
python-version: "3.x"
|
| 20 |
+
- name: Install pypa/build
|
| 21 |
+
run: >-
|
| 22 |
+
python3 -m
|
| 23 |
+
pip install
|
| 24 |
+
build
|
| 25 |
+
--user
|
| 26 |
+
- name: Build a binary wheel and a source tarball
|
| 27 |
+
run: python3 -m build
|
| 28 |
+
- name: Store the distribution packages
|
| 29 |
+
uses: actions/upload-artifact@v4
|
| 30 |
+
with:
|
| 31 |
+
name: python-package-distributions
|
| 32 |
+
path: dist/
|
| 33 |
+
|
| 34 |
+
publish-to-pypi:
|
| 35 |
+
name: >-
|
| 36 |
+
Publish Python 🐍 distribution 📦 to PyPI
|
| 37 |
+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
|
| 38 |
+
needs:
|
| 39 |
+
- build
|
| 40 |
+
runs-on: ubuntu-latest
|
| 41 |
+
environment:
|
| 42 |
+
name: pypi
|
| 43 |
+
url: https://pypi.org/p/voxcpm
|
| 44 |
+
permissions:
|
| 45 |
+
id-token: write
|
| 46 |
+
|
| 47 |
+
steps:
|
| 48 |
+
- name: Download all the dists
|
| 49 |
+
uses: actions/download-artifact@v4
|
| 50 |
+
with:
|
| 51 |
+
name: python-package-distributions
|
| 52 |
+
path: dist/
|
| 53 |
+
- name: Publish distribution 📦 to PyPI
|
| 54 |
+
uses: pypa/gh-action-pypi-publish@release/v1
|
VoxCPM/.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
launch.json
|
| 2 |
+
__pycache__
|
| 3 |
+
voxcpm.egg-info
|
VoxCPM/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright OpenBMB
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
VoxCPM/README.md
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## 🎙️ VoxCPM: Tokenizer-Free TTS for Context-Aware Speech Generation and True-to-Life Voice Cloning
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
[](https://github.com/OpenBMB/VoxCPM/) [](https://arxiv.org/abs/2509.24650) [](https://huggingface.co/openbmb/VoxCPM-0.5B) [](https://modelscope.cn/models/OpenBMB/VoxCPM-0.5B) [](https://huggingface.co/spaces/OpenBMB/VoxCPM-Demo) [](https://openbmb.github.io/VoxCPM-demopage)
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
<div align="center">
|
| 9 |
+
<img src="assets/voxcpm_logo.png" alt="VoxCPM Logo" width="40%">
|
| 10 |
+
</div>
|
| 11 |
+
|
| 12 |
+
<div align="center">
|
| 13 |
+
|
| 14 |
+
👋 Contact us on [WeChat](assets/wechat.png)
|
| 15 |
+
|
| 16 |
+
</div>
|
| 17 |
+
|
| 18 |
+
## News
|
| 19 |
+
* [2025.09.30] 🔥 🔥 🔥 We Release VoxCPM [Technical Report](https://arxiv.org/abs/2509.24650)!
|
| 20 |
+
* [2025.09.16] 🔥 🔥 🔥 We Open Source the VoxCPM-0.5B [weights](https://huggingface.co/openbmb/VoxCPM-0.5B)!
|
| 21 |
+
* [2025.09.16] 🎉 🎉 🎉 We Provide the [Gradio PlayGround](https://huggingface.co/spaces/OpenBMB/VoxCPM-Demo) for VoxCPM-0.5B, try it now!
|
| 22 |
+
|
| 23 |
+
## Overview
|
| 24 |
+
|
| 25 |
+
VoxCPM is a novel tokenizer-free Text-to-Speech (TTS) system that redefines realism in speech synthesis. By modeling speech in a continuous space, it overcomes the limitations of discrete tokenization and enables two flagship capabilities: context-aware speech generation and true-to-life zero-shot voice cloning.
|
| 26 |
+
|
| 27 |
+
Unlike mainstream approaches that convert speech to discrete tokens, VoxCPM uses an end-to-end diffusion autoregressive architecture that directly generates continuous speech representations from text. Built on [MiniCPM-4](https://huggingface.co/openbmb/MiniCPM4-0.5B) backbone, it achieves implicit semantic-acoustic decoupling through hierachical language modeling and FSQ constraints, greatly enhancing both expressiveness and generation stability.
|
| 28 |
+
|
| 29 |
+
<div align="center">
|
| 30 |
+
<img src="assets/voxcpm_model.png" alt="VoxCPM Model Architecture" width="90%">
|
| 31 |
+
</div>
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
### 🚀 Key Features
|
| 35 |
+
- **Context-Aware, Expressive Speech Generation** - VoxCPM comprehends text to infer and generate appropriate prosody, delivering speech with remarkable expressiveness and natural flow. It spontaneously adapts speaking style based on content, producing highly fitting vocal expression trained on a massive 1.8 million-hour bilingual corpus.
|
| 36 |
+
- **True-to-Life Voice Cloning** - With only a short reference audio clip, VoxCPM performs accurate zero-shot voice cloning, capturing not only the speaker’s timbre but also fine-grained characteristics such as accent, emotional tone, rhythm, and pacing to create a faithful and natural replica.
|
| 37 |
+
- **High-Efficiency Synthesis** - VoxCPM supports streaming synthesis with a Real-Time Factor (RTF) as low as 0.17 on a consumer-grade NVIDIA RTX 4090 GPU, making it possible for real-time applications.
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
## Quick Start
|
| 44 |
+
|
| 45 |
+
### 🔧 Install from PyPI
|
| 46 |
+
``` sh
|
| 47 |
+
pip install voxcpm
|
| 48 |
+
```
|
| 49 |
+
### 1. Model Download (Optional)
|
| 50 |
+
By default, when you first run the script, the model will be downloaded automatically, but you can also download the model in advance.
|
| 51 |
+
- Download VoxCPM-0.5B
|
| 52 |
+
```
|
| 53 |
+
from huggingface_hub import snapshot_download
|
| 54 |
+
snapshot_download("openbmb/VoxCPM-0.5B")
|
| 55 |
+
```
|
| 56 |
+
- Download ZipEnhancer and SenseVoice-Small. We use ZipEnhancer to enhance speech prompts and SenseVoice-Small for speech prompt ASR in the web demo.
|
| 57 |
+
```
|
| 58 |
+
from modelscope import snapshot_download
|
| 59 |
+
snapshot_download('iic/speech_zipenhancer_ans_multiloss_16k_base')
|
| 60 |
+
snapshot_download('iic/SenseVoiceSmall')
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
### 2. Basic Usage
|
| 64 |
+
```python
|
| 65 |
+
import soundfile as sf
|
| 66 |
+
import numpy as np
|
| 67 |
+
from voxcpm import VoxCPM
|
| 68 |
+
|
| 69 |
+
model = VoxCPM.from_pretrained("openbmb/VoxCPM-0.5B")
|
| 70 |
+
|
| 71 |
+
# Non-streaming
|
| 72 |
+
wav = model.generate(
|
| 73 |
+
text="VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech.",
|
| 74 |
+
prompt_wav_path=None, # optional: path to a prompt speech for voice cloning
|
| 75 |
+
prompt_text=None, # optional: reference text
|
| 76 |
+
cfg_value=2.0, # LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse
|
| 77 |
+
inference_timesteps=10, # LocDiT inference timesteps, higher for better result, lower for fast speed
|
| 78 |
+
normalize=True, # enable external TN tool
|
| 79 |
+
denoise=True, # enable external Denoise tool
|
| 80 |
+
retry_badcase=True, # enable retrying mode for some bad cases (unstoppable)
|
| 81 |
+
retry_badcase_max_times=3, # maximum retrying times
|
| 82 |
+
retry_badcase_ratio_threshold=6.0, # maximum length restriction for bad case detection (simple but effective), it could be adjusted for slow pace speech
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
sf.write("output.wav", wav, 16000)
|
| 86 |
+
print("saved: output.wav")
|
| 87 |
+
|
| 88 |
+
# Streaming
|
| 89 |
+
chunks = []
|
| 90 |
+
for chunk in model.generate_streaming(
|
| 91 |
+
text = "Streaming text to speech is easy with VoxCPM!",
|
| 92 |
+
# supports same args as above
|
| 93 |
+
):
|
| 94 |
+
chunks.append(chunk)
|
| 95 |
+
wav = np.concatenate(chunks)
|
| 96 |
+
|
| 97 |
+
sf.write("output_streaming.wav", wav, 16000)
|
| 98 |
+
print("saved: output_streaming.wav")
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
### 3. CLI Usage
|
| 102 |
+
|
| 103 |
+
After installation, the entry point is `voxcpm` (or use `python -m voxcpm.cli`).
|
| 104 |
+
|
| 105 |
+
```bash
|
| 106 |
+
# 1) Direct synthesis (single text)
|
| 107 |
+
voxcpm --text "VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech." --output out.wav
|
| 108 |
+
|
| 109 |
+
# 2) Voice cloning (reference audio + transcript)
|
| 110 |
+
voxcpm --text "VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech." \
|
| 111 |
+
--prompt-audio path/to/voice.wav \
|
| 112 |
+
--prompt-text "reference transcript" \
|
| 113 |
+
--output out.wav \
|
| 114 |
+
--denoise
|
| 115 |
+
|
| 116 |
+
# (Optinal) Voice cloning (reference audio + transcript file)
|
| 117 |
+
voxcpm --text "VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech." \
|
| 118 |
+
--prompt-audio path/to/voice.wav \
|
| 119 |
+
--prompt-file "/path/to/text-file" \
|
| 120 |
+
--output out.wav \
|
| 121 |
+
--denoise
|
| 122 |
+
|
| 123 |
+
# 3) Batch processing (one text per line)
|
| 124 |
+
voxcpm --input examples/input.txt --output-dir outs
|
| 125 |
+
# (optional) Batch + cloning
|
| 126 |
+
voxcpm --input examples/input.txt --output-dir outs \
|
| 127 |
+
--prompt-audio path/to/voice.wav \
|
| 128 |
+
--prompt-text "reference transcript" \
|
| 129 |
+
--denoise
|
| 130 |
+
|
| 131 |
+
# 4) Inference parameters (quality/speed)
|
| 132 |
+
voxcpm --text "..." --output out.wav \
|
| 133 |
+
--cfg-value 2.0 --inference-timesteps 10 --normalize
|
| 134 |
+
|
| 135 |
+
# 5) Model loading
|
| 136 |
+
# Prefer local path
|
| 137 |
+
voxcpm --text "..." --output out.wav --model-path /path/to/VoxCPM_model_dir
|
| 138 |
+
# Or from Hugging Face (auto download/cache)
|
| 139 |
+
voxcpm --text "..." --output out.wav \
|
| 140 |
+
--hf-model-id openbmb/VoxCPM-0.5B --cache-dir ~/.cache/huggingface --local-files-only
|
| 141 |
+
|
| 142 |
+
# 6) Denoiser control
|
| 143 |
+
voxcpm --text "..." --output out.wav \
|
| 144 |
+
--no-denoiser --zipenhancer-path iic/speech_zipenhancer_ans_multiloss_16k_base
|
| 145 |
+
|
| 146 |
+
# 7) Help
|
| 147 |
+
voxcpm --help
|
| 148 |
+
python -m voxcpm.cli --help
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
### 4. Start web demo
|
| 152 |
+
|
| 153 |
+
You can start the UI interface by running `python app.py`, which allows you to perform Voice Cloning and Voice Creation.
|
| 154 |
+
|
| 155 |
+
## 🛠️ Fine-tune VoxCPM
|
| 156 |
+
|
| 157 |
+
We provide a training pipeline mirroring the `minicpm-audio` workflow while relying purely on HuggingFace `datasets` for audio-text management.
|
| 158 |
+
|
| 159 |
+
1. **Prepare a manifest (JSONL)**
|
| 160 |
+
|
| 161 |
+
```
|
| 162 |
+
{"audio": "/path/to/audio_0001.wav", "text": "你好,世界。", "dataset_id": 0}
|
| 163 |
+
{"audio": "/path/to/audio_0002.wav", "text": "第二条语音", "dataset_id": 0}
|
| 164 |
+
```
|
| 165 |
+
- `audio`: waveform file path (WAV/FLAC/MP3 supported)
|
| 166 |
+
- `text`: transcription
|
| 167 |
+
- `dataset_id` *(optional)*: integer identifier for multi-dataset sampling statistics
|
| 168 |
+
|
| 169 |
+
2. **Copy & edit the example config**
|
| 170 |
+
`conf/voxcpm/voxcpm_finetune_example.yaml` contains hyper-parameters (pretrained weights, tokenizer, manifests, λ-weights, etc.).
|
| 171 |
+
|
| 172 |
+
3. **Launch training**
|
| 173 |
+
|
| 174 |
+
```bash
|
| 175 |
+
CUDA_VISIBLE_DEVICES=0,1 torchrun --nproc_per_node 2 \
|
| 176 |
+
scripts/train_voxcpm_finetune.py \
|
| 177 |
+
--config_path conf/voxcpm/voxcpm_finetune_example.yaml
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
Features:
|
| 181 |
+
- Distributed + AMP training (`torchrun`).
|
| 182 |
+
- TensorBoard logging (`tensorboard --logdir logs/voxcpm_finetune`).
|
| 183 |
+
- Periodic validation & checkpointing under `checkpoints/`.
|
| 184 |
+
|
| 185 |
+
4. **Key modules**
|
| 186 |
+
- `src/voxcpm/model/voxcpm.py`: unified model providing both inference and training forward。
|
| 187 |
+
- `src/voxcpm/training/`: accelerator, tracker, dataset loader & batch packer utilities。
|
| 188 |
+
- `scripts/train_voxcpm_finetune.py`: end-to-end fine-tune loop。
|
| 189 |
+
|
| 190 |
+
## 👩🍳 A Voice Chef's Guide
|
| 191 |
+
Welcome to the VoxCPM kitchen! Follow this recipe to cook up perfect generated speech. Let’s begin.
|
| 192 |
+
|
| 193 |
+
---
|
| 194 |
+
### 🥚 Step 1: Prepare Your Base Ingredients (Content)
|
| 195 |
+
|
| 196 |
+
First, choose how you’d like to input your text:.
|
| 197 |
+
1. Regular Text (Classic Mode)
|
| 198 |
+
- ✅ Keep "Text Normalization" ON. Type naturally (e.g., "Hello, world! 123"). The system will automatically process numbers, abbreviations, and punctuation using WeTextProcessing library.
|
| 199 |
+
2. Phoneme Input (Native Mode)
|
| 200 |
+
- ❌ Turn "Text Normalization" OFF. Enter phoneme text like {HH AH0 L OW1} (EN) or {ni3}{hao3} (ZH) for precise pronunciation control. In this mode, VoxCPM also supports native understanding of other complex non-normalized text—try it out!
|
| 201 |
+
|
| 202 |
+
---
|
| 203 |
+
### 🍳 Step 2: Choose Your Flavor Profile (Voice Style)
|
| 204 |
+
|
| 205 |
+
This is the secret sauce that gives your audio its unique sound.
|
| 206 |
+
1. Cooking with a Prompt Speech (Following a Famous Recipe)
|
| 207 |
+
- A prompt speech provides the desired acoustic characteristics for VoxCPM. The speaker's timbre, speaking style, and even the background sounds and ambiance will be replicated.
|
| 208 |
+
- For a Clean, Studio-Quality Voice:
|
| 209 |
+
- ✅ Enable "Prompt Speech Enhancement". This acts like a noise filter, removing background hiss and rumble to give you a pure, clean voice clone.
|
| 210 |
+
2. Cooking au Naturel (Letting the Model Improvise)
|
| 211 |
+
- If no reference is provided, VoxCPM becomes a creative chef! It will infer a fitting speaking style based on the text itself, thanks to the text-smartness of its foundation model, MiniCPM-4.
|
| 212 |
+
- Pro Tip: Challenge VoxCPM with any text—poetry, song lyrics, dramatic monologues—it may deliver some interesting results!
|
| 213 |
+
|
| 214 |
+
---
|
| 215 |
+
### 🧂 Step 3: The Final Seasoning (Fine-Tuning Your Results)
|
| 216 |
+
You're ready to serve! But for master chefs who want to tweak the flavor, here are two key spices.
|
| 217 |
+
- CFG Value (How Closely to Follow the Recipe)
|
| 218 |
+
- Default: A great starting point.
|
| 219 |
+
- Voice sounds strained or weird? Lower this value. It tells the model to be more relaxed and improvisational, great for expressive prompts.
|
| 220 |
+
- Need maximum clarity and adherence to the text? Raise it slightly to keep the model on a tighter leash.
|
| 221 |
+
- Inference Timesteps (Simmering Time: Quality vs. Speed)
|
| 222 |
+
- Need a quick snack? Use a lower number. Perfect for fast drafts and experiments.
|
| 223 |
+
- Cooking a gourmet meal? Use a higher number. This lets the model "simmer" longer, refining the audio for superior detail and naturalness.
|
| 224 |
+
|
| 225 |
+
---
|
| 226 |
+
Happy creating! 🎉 Start with the default settings and tweak from there to suit your project. The kitchen is yours!
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
---
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
## 🌟 Community Projects
|
| 233 |
+
|
| 234 |
+
We're excited to see the VoxCPM community growing! Here are some amazing projects and features built by our community:
|
| 235 |
+
|
| 236 |
+
- **[ComfyUI-VoxCPM](https://github.com/wildminder/ComfyUI-VoxCPM)**
|
| 237 |
+
- **[ComfyUI-VoxCPMTTS](https://github.com/1038lab/ComfyUI-VoxCPMTTS)**
|
| 238 |
+
- **[WebUI-VoxCPM](https://github.com/rsxdalv/tts_webui_extension.vox_cpm)**
|
| 239 |
+
- **[PR: Streaming API Support (by AbrahamSanders)](https://github.com/OpenBMB/VoxCPM/pull/26)**
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
*Have you built something cool with VoxCPM? We'd love to feature it here! Please open an issue or pull request to add your project.*
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
## 📊 Performance Highlights
|
| 247 |
+
|
| 248 |
+
VoxCPM achieves competitive results on public zero-shot TTS benchmarks:
|
| 249 |
+
|
| 250 |
+
### Seed-TTS-eval Benchmark
|
| 251 |
+
|
| 252 |
+
| Model | Parameters | Open-Source | test-EN | | test-ZH | | test-Hard | |
|
| 253 |
+
|------|------|------|:------------:|:--:|:------------:|:--:|:-------------:|:--:|
|
| 254 |
+
| | | | WER/%⬇ | SIM/%⬆| CER/%⬇| SIM/%⬆ | CER/%⬇ | SIM/%⬆ |
|
| 255 |
+
| MegaTTS3 | 0.5B | ❌ | 2.79 | 77.1 | 1.52 | 79.0 | - | - |
|
| 256 |
+
| DiTAR | 0.6B | ❌ | 1.69 | 73.5 | 1.02 | 75.3 | - | - |
|
| 257 |
+
| CosyVoice3 | 0.5B | ❌ | 2.02 | 71.8 | 1.16 | 78.0 | 6.08 | 75.8 |
|
| 258 |
+
| CosyVoice3 | 1.5B | ❌ | 2.22 | 72.0 | 1.12 | 78.1 | 5.83 | 75.8 |
|
| 259 |
+
| Seed-TTS | - | ❌ | 2.25 | 76.2 | 1.12 | 79.6 | 7.59 | 77.6 |
|
| 260 |
+
| MiniMax-Speech | - | ❌ | 1.65 | 69.2 | 0.83 | 78.3 | - | - |
|
| 261 |
+
| CosyVoice | 0.3B | ✅ | 4.29 | 60.9 | 3.63 | 72.3 | 11.75 | 70.9 |
|
| 262 |
+
| CosyVoice2 | 0.5B | ✅ | 3.09 | 65.9 | 1.38 | 75.7 | **6.83** | 72.4 |
|
| 263 |
+
| F5-TTS | 0.3B | ✅ | 2.00 | 67.0 | 1.53 | 76.0 | 8.67 | 71.3 |
|
| 264 |
+
| SparkTTS | 0.5B | ✅ | 3.14 | 57.3 | 1.54 | 66.0 | - | - |
|
| 265 |
+
| FireRedTTS | 0.5B | ✅ | 3.82 | 46.0 | 1.51 | 63.5 | 17.45 | 62.1 |
|
| 266 |
+
| FireRedTTS-2 | 1.5B | ✅ | 1.95 | 66.5 | 1.14 | 73.6 | - | - |
|
| 267 |
+
| Qwen2.5-Omni | 7B | ✅ | 2.72 | 63.2 | 1.70 | 75.2 | 7.97 | **74.7** |
|
| 268 |
+
| OpenAudio-s1-mini | 0.5B | ✅ | 1.94 | 55.0 | 1.18 | 68.5 | - | - |
|
| 269 |
+
| IndexTTS2 | 1.5B | ✅ | 2.23 | 70.6 | 1.03 | 76.5 | - | - |
|
| 270 |
+
| VibeVoice | 1.5B | ✅ | 3.04 | 68.9 | 1.16 | 74.4 | - | - |
|
| 271 |
+
| HiggsAudio-v2 | 3B | ✅ | 2.44 | 67.7 | 1.50 | 74.0 | - | - |
|
| 272 |
+
| **VoxCPM** | 0.5B | ✅ | **1.85** | **72.9** | **0.93** | **77.2** | 8.87 | 73.0 |
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
### CV3-eval Benchmark
|
| 276 |
+
|
| 277 |
+
| Model | zh | en | hard-zh | | | hard-en | | |
|
| 278 |
+
|-------|:--:|:--:|:-------:|:--:|:--:|:-------:|:--:|:--:|
|
| 279 |
+
| | CER/%⬇ | WER/%⬇ | CER/%⬇ | SIM/%⬆ | DNSMOS⬆ | WER/%⬇ | SIM/%⬆ | DNSMOS⬆ |
|
| 280 |
+
| F5-TTS | 5.47 | 8.90 | - | - | - | - | - | - |
|
| 281 |
+
| SparkTTS | 5.15 | 11.0 | - | - | - | - | - | - |
|
| 282 |
+
| GPT-SoVits | 7.34 | 12.5 | - | - | - | - | - | - |
|
| 283 |
+
| CosyVoice2 | 4.08 | 6.32 | 12.58 | 72.6 | 3.81 | 11.96 | 66.7 | 3.95 |
|
| 284 |
+
| OpenAudio-s1-mini | 4.00 | 5.54 | 18.1 | 58.2 | 3.77 | 12.4 | 55.7 | 3.89 |
|
| 285 |
+
| IndexTTS2 | 3.58 | 4.45 | 12.8 | 74.6 | 3.65 | - | - | - |
|
| 286 |
+
| HiggsAudio-v2 | 9.54 | 7.89 | 41.0 | 60.2 | 3.39 | 10.3 | 61.8 | 3.68 |
|
| 287 |
+
| CosyVoice3-0.5B | 3.89 | 5.24 | 14.15 | 78.6 | 3.75 | 9.04 | 75.9 | 3.92 |
|
| 288 |
+
| CosyVoice3-1.5B | 3.91 | 4.99 | 9.77 | 78.5 | 3.79 | 10.55 | 76.1 | 3.95 |
|
| 289 |
+
| **VoxCPM** | **3.40** | **4.04** | 12.9 | 66.1 | 3.59 | **7.89** | 64.3 | 3.74 |
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
## ⚠️ Risks and limitations
|
| 303 |
+
- General Model Behavior: While VoxCPM has been trained on a large-scale dataset, it may still produce outputs that are unexpected, biased, or contain artifacts.
|
| 304 |
+
- Potential for Misuse of Voice Cloning: VoxCPM's powerful zero-shot voice cloning capability can generate highly realistic synthetic speech. This technology could be misused for creating convincing deepfakes for purposes of impersonation, fraud, or spreading disinformation. Users of this model must not use it to create content that infringes upon the rights of individuals. It is strictly forbidden to use VoxCPM for any illegal or unethical purposes. We strongly recommend that any publicly shared content generated with this model be clearly marked as AI-generated.
|
| 305 |
+
- Current Technical Limitations: Although generally stable, the model may occasionally exhibit instability, especially with very long or expressive inputs. Furthermore, the current version offers limited direct control over specific speech attributes like emotion or speaking style.
|
| 306 |
+
- Bilingual Model: VoxCPM is trained primarily on Chinese and English data. Performance on other languages is not guaranteed and may result in unpredictable or low-quality audio.
|
| 307 |
+
- This model is released for research and development purposes only. We do not recommend its use in production or commercial applications without rigorous testing and safety evaluations. Please use VoxCPM responsibly.
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
## 📝TO-DO List
|
| 312 |
+
Please stay tuned for updates!
|
| 313 |
+
- [x] Release the VoxCPM technical report.
|
| 314 |
+
- [ ] Support higher sampling rate (next version).
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
## 📄 License
|
| 319 |
+
The VoxCPM model weights and code are open-sourced under the [Apache-2.0](LICENSE) license.
|
| 320 |
+
|
| 321 |
+
## 🙏 Acknowledgments
|
| 322 |
+
|
| 323 |
+
We extend our sincere gratitude to the following works and resources for their inspiration and contributions:
|
| 324 |
+
|
| 325 |
+
- [DiTAR](https://arxiv.org/abs/2502.03930) for the diffusion autoregressive backbone used in speech generation
|
| 326 |
+
- [MiniCPM-4](https://github.com/OpenBMB/MiniCPM) for serving as the language model foundation
|
| 327 |
+
- [CosyVoice](https://github.com/FunAudioLLM/CosyVoice) for the implementation of Flow Matching-based LocDiT
|
| 328 |
+
- [DAC](https://github.com/descriptinc/descript-audio-codec) for providing the Audio VAE backbone
|
| 329 |
+
|
| 330 |
+
## Institutions
|
| 331 |
+
|
| 332 |
+
This project is developed by the following institutions:
|
| 333 |
+
- <img src="assets/modelbest_logo.png" width="28px"> [ModelBest](https://modelbest.cn/)
|
| 334 |
+
|
| 335 |
+
- <img src="assets/thuhcsi_logo.png" width="28px"> [THUHCSI](https://github.com/thuhcsi)
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
## ⭐ Star History
|
| 339 |
+
[](https://star-history.com/#OpenBMB/VoxCPM&Date)
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
## 📚 Citation
|
| 343 |
+
|
| 344 |
+
If you find our model helpful, please consider citing our projects 📝 and staring us ⭐️!
|
| 345 |
+
|
| 346 |
+
```bib
|
| 347 |
+
@article{voxcpm2025,
|
| 348 |
+
title = {VoxCPM: Tokenizer-Free TTS for Context-Aware Speech Generation and True-to-Life Voice Cloning},
|
| 349 |
+
author = {Zhou, Yixuan and Zeng, Guoyang and Liu, Xin and Li, Xiang and Yu, Renjie and Wang, Ziyang and Ye, Runchuan and Sun, Weiyue and Gui, Jiancheng and Li, Kehan and Wu, Zhiyong and Liu, Zhiyuan},
|
| 350 |
+
journal = {arXiv preprint arXiv:2509.24650},
|
| 351 |
+
year = {2025},
|
| 352 |
+
}
|
| 353 |
+
```
|
VoxCPM/app.py
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import numpy as np
|
| 3 |
+
import torch
|
| 4 |
+
import gradio as gr
|
| 5 |
+
import spaces
|
| 6 |
+
from typing import Optional, Tuple
|
| 7 |
+
from funasr import AutoModel
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
| 10 |
+
if os.environ.get("HF_REPO_ID", "").strip() == "":
|
| 11 |
+
os.environ["HF_REPO_ID"] = "openbmb/VoxCPM-0.5B"
|
| 12 |
+
|
| 13 |
+
import voxcpm
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class VoxCPMDemo:
|
| 17 |
+
def __init__(self) -> None:
|
| 18 |
+
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 19 |
+
print(f"🚀 Running on device: {self.device}")
|
| 20 |
+
|
| 21 |
+
# ASR model for prompt text recognition
|
| 22 |
+
self.asr_model_id = "iic/SenseVoiceSmall"
|
| 23 |
+
self.asr_model: Optional[AutoModel] = AutoModel(
|
| 24 |
+
model=self.asr_model_id,
|
| 25 |
+
disable_update=True,
|
| 26 |
+
log_level='DEBUG',
|
| 27 |
+
device="cuda:0" if self.device == "cuda" else "cpu",
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
# TTS model (lazy init)
|
| 31 |
+
self.voxcpm_model: Optional[voxcpm.VoxCPM] = None
|
| 32 |
+
self.default_local_model_dir = "./models/VoxCPM-0.5B"
|
| 33 |
+
|
| 34 |
+
# ---------- Model helpers ----------
|
| 35 |
+
def _resolve_model_dir(self) -> str:
|
| 36 |
+
"""
|
| 37 |
+
Resolve model directory:
|
| 38 |
+
1) Use local checkpoint directory if exists
|
| 39 |
+
2) If HF_REPO_ID env is set, download into models/{repo}
|
| 40 |
+
3) Fallback to 'models'
|
| 41 |
+
"""
|
| 42 |
+
if os.path.isdir(self.default_local_model_dir):
|
| 43 |
+
return self.default_local_model_dir
|
| 44 |
+
|
| 45 |
+
repo_id = os.environ.get("HF_REPO_ID", "").strip()
|
| 46 |
+
if len(repo_id) > 0:
|
| 47 |
+
target_dir = os.path.join("models", repo_id.replace("/", "__"))
|
| 48 |
+
if not os.path.isdir(target_dir):
|
| 49 |
+
try:
|
| 50 |
+
from huggingface_hub import snapshot_download # type: ignore
|
| 51 |
+
os.makedirs(target_dir, exist_ok=True)
|
| 52 |
+
print(f"Downloading model from HF repo '{repo_id}' to '{target_dir}' ...")
|
| 53 |
+
snapshot_download(repo_id=repo_id, local_dir=target_dir, local_dir_use_symlinks=False)
|
| 54 |
+
except Exception as e:
|
| 55 |
+
print(f"Warning: HF download failed: {e}. Falling back to 'data'.")
|
| 56 |
+
return "models"
|
| 57 |
+
return target_dir
|
| 58 |
+
return "models"
|
| 59 |
+
|
| 60 |
+
def get_or_load_voxcpm(self) -> voxcpm.VoxCPM:
|
| 61 |
+
if self.voxcpm_model is not None:
|
| 62 |
+
return self.voxcpm_model
|
| 63 |
+
print("Model not loaded, initializing...")
|
| 64 |
+
model_dir = self._resolve_model_dir()
|
| 65 |
+
print(f"Using model dir: {model_dir}")
|
| 66 |
+
self.voxcpm_model = voxcpm.VoxCPM(voxcpm_model_path=model_dir)
|
| 67 |
+
print("Model loaded successfully.")
|
| 68 |
+
return self.voxcpm_model
|
| 69 |
+
|
| 70 |
+
# ---------- Functional endpoints ----------
|
| 71 |
+
def prompt_wav_recognition(self, prompt_wav: Optional[str]) -> str:
|
| 72 |
+
if prompt_wav is None:
|
| 73 |
+
return ""
|
| 74 |
+
res = self.asr_model.generate(input=prompt_wav, language="auto", use_itn=True)
|
| 75 |
+
text = res[0]["text"].split('|>')[-1]
|
| 76 |
+
return text
|
| 77 |
+
|
| 78 |
+
def generate_tts_audio(
|
| 79 |
+
self,
|
| 80 |
+
text_input: str,
|
| 81 |
+
prompt_wav_path_input: Optional[str] = None,
|
| 82 |
+
prompt_text_input: Optional[str] = None,
|
| 83 |
+
cfg_value_input: float = 2.0,
|
| 84 |
+
inference_timesteps_input: int = 10,
|
| 85 |
+
do_normalize: bool = True,
|
| 86 |
+
denoise: bool = True,
|
| 87 |
+
) -> Tuple[int, np.ndarray]:
|
| 88 |
+
"""
|
| 89 |
+
Generate speech from text using VoxCPM; optional reference audio for voice style guidance.
|
| 90 |
+
Returns (sample_rate, waveform_numpy)
|
| 91 |
+
"""
|
| 92 |
+
current_model = self.get_or_load_voxcpm()
|
| 93 |
+
|
| 94 |
+
text = (text_input or "").strip()
|
| 95 |
+
if len(text) == 0:
|
| 96 |
+
raise ValueError("Please input text to synthesize.")
|
| 97 |
+
|
| 98 |
+
prompt_wav_path = prompt_wav_path_input if prompt_wav_path_input else None
|
| 99 |
+
prompt_text = prompt_text_input if prompt_text_input else None
|
| 100 |
+
|
| 101 |
+
print(f"Generating audio for text: '{text[:60]}...'")
|
| 102 |
+
wav = current_model.generate(
|
| 103 |
+
text=text,
|
| 104 |
+
prompt_text=prompt_text,
|
| 105 |
+
prompt_wav_path=prompt_wav_path,
|
| 106 |
+
cfg_value=float(cfg_value_input),
|
| 107 |
+
inference_timesteps=int(inference_timesteps_input),
|
| 108 |
+
normalize=do_normalize,
|
| 109 |
+
denoise=denoise,
|
| 110 |
+
)
|
| 111 |
+
return (16000, wav)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
# ---------- UI Builders ----------
|
| 115 |
+
|
| 116 |
+
def create_demo_interface(demo: VoxCPMDemo):
|
| 117 |
+
"""Build the Gradio UI for VoxCPM demo."""
|
| 118 |
+
# static assets (logo path)
|
| 119 |
+
gr.set_static_paths(paths=[Path.cwd().absolute()/"assets"])
|
| 120 |
+
|
| 121 |
+
with gr.Blocks(
|
| 122 |
+
theme=gr.themes.Soft(
|
| 123 |
+
primary_hue="blue",
|
| 124 |
+
secondary_hue="gray",
|
| 125 |
+
neutral_hue="slate",
|
| 126 |
+
font=[gr.themes.GoogleFont("Inter"), "Arial", "sans-serif"]
|
| 127 |
+
),
|
| 128 |
+
css="""
|
| 129 |
+
.logo-container {
|
| 130 |
+
text-align: center;
|
| 131 |
+
margin: 0.5rem 0 1rem 0;
|
| 132 |
+
}
|
| 133 |
+
.logo-container img {
|
| 134 |
+
height: 80px;
|
| 135 |
+
width: auto;
|
| 136 |
+
max-width: 200px;
|
| 137 |
+
display: inline-block;
|
| 138 |
+
}
|
| 139 |
+
/* Bold accordion labels */
|
| 140 |
+
#acc_quick details > summary,
|
| 141 |
+
#acc_tips details > summary {
|
| 142 |
+
font-weight: 600 !important;
|
| 143 |
+
font-size: 1.1em !important;
|
| 144 |
+
}
|
| 145 |
+
/* Bold labels for specific checkboxes */
|
| 146 |
+
#chk_denoise label,
|
| 147 |
+
#chk_denoise span,
|
| 148 |
+
#chk_normalize label,
|
| 149 |
+
#chk_normalize span {
|
| 150 |
+
font-weight: 600;
|
| 151 |
+
}
|
| 152 |
+
"""
|
| 153 |
+
) as interface:
|
| 154 |
+
# Header logo
|
| 155 |
+
gr.HTML('<div class="logo-container"><img src="/gradio_api/file=assets/voxcpm_logo.png" alt="VoxCPM Logo"></div>')
|
| 156 |
+
|
| 157 |
+
# Quick Start
|
| 158 |
+
with gr.Accordion("📋 Quick Start Guide |快速入门", open=False, elem_id="acc_quick"):
|
| 159 |
+
gr.Markdown("""
|
| 160 |
+
### How to Use |使用说明
|
| 161 |
+
1. **(Optional) Provide a Voice Prompt** - Upload or record an audio clip to provide the desired voice characteristics for synthesis.
|
| 162 |
+
**(可选)提供参考声音** - 上传或录制一段音频,为声音合成提供音色、语调和情感等个性化特征
|
| 163 |
+
2. **(Optional) Enter prompt text** - If you provided a voice prompt, enter the corresponding transcript here (auto-recognition available).
|
| 164 |
+
**(可选项)输入参考文本** - 如果提供了参考语音,请输入其对应的文本内容(支持自动识别)。
|
| 165 |
+
3. **Enter target text** - Type the text you want the model to speak.
|
| 166 |
+
**输入目标文本** - 输入您希望模型朗读的文字内容。
|
| 167 |
+
4. **Generate Speech** - Click the "Generate" button to create your audio.
|
| 168 |
+
**生成语音** - 点击"生成"按钮,即可为您创造出音频。
|
| 169 |
+
""")
|
| 170 |
+
|
| 171 |
+
# Pro Tips
|
| 172 |
+
with gr.Accordion("💡 Pro Tips |使用建议", open=False, elem_id="acc_tips"):
|
| 173 |
+
gr.Markdown("""
|
| 174 |
+
### Prompt Speech Enhancement|参考语音降噪
|
| 175 |
+
- **Enable** to remove background noise for a clean, studio-like voice, with an external ZipEnhancer component.
|
| 176 |
+
**启用**:通过 ZipEnhancer 组件消除背景噪音,获得更好的音质。
|
| 177 |
+
- **Disable** to preserve the original audio's background atmosphere.
|
| 178 |
+
**禁用**:保留原始音频的背景环境声,如果想复刻相应声学环境。
|
| 179 |
+
|
| 180 |
+
### Text Normalization|文本正则化
|
| 181 |
+
- **Enable** to process general text with an external WeTextProcessing component.
|
| 182 |
+
**启用**:使用 WeTextProcessing 组件,可处理常见文本。
|
| 183 |
+
- **Disable** to use VoxCPM's native text understanding ability. For example, it supports phonemes input ({HH AH0 L OW1}), try it!
|
| 184 |
+
**禁用**:将使用 VoxCPM 内置的文本理解能力。如,支持音素输入(如 {da4}{jia1}好)和公式符号合成,尝试一下!
|
| 185 |
+
|
| 186 |
+
### CFG Value|CFG 值
|
| 187 |
+
- **Lower CFG** if the voice prompt sounds strained or expressive.
|
| 188 |
+
**调低**:如果提示语音听起来不自然或过于夸张。
|
| 189 |
+
- **Higher CFG** for better adherence to the prompt speech style or input text.
|
| 190 |
+
**调高**:为更好地贴合提示音频的风格或输入文本。
|
| 191 |
+
|
| 192 |
+
### Inference Timesteps|推理时间步
|
| 193 |
+
- **Lower** for faster synthesis speed.
|
| 194 |
+
**调低**:合成速度更快。
|
| 195 |
+
- **Higher** for better synthesis quality.
|
| 196 |
+
**调高**:合成质量更佳。
|
| 197 |
+
""")
|
| 198 |
+
|
| 199 |
+
# Main controls
|
| 200 |
+
with gr.Row():
|
| 201 |
+
with gr.Column():
|
| 202 |
+
prompt_wav = gr.Audio(
|
| 203 |
+
sources=["upload", 'microphone'],
|
| 204 |
+
type="filepath",
|
| 205 |
+
label="Prompt Speech (Optional, or let VoxCPM improvise)",
|
| 206 |
+
value="./examples/example.wav",
|
| 207 |
+
)
|
| 208 |
+
DoDenoisePromptAudio = gr.Checkbox(
|
| 209 |
+
value=False,
|
| 210 |
+
label="Prompt Speech Enhancement",
|
| 211 |
+
elem_id="chk_denoise",
|
| 212 |
+
info="We use ZipEnhancer model to denoise the prompt audio."
|
| 213 |
+
)
|
| 214 |
+
with gr.Row():
|
| 215 |
+
prompt_text = gr.Textbox(
|
| 216 |
+
value="Just by listening a few minutes a day, you'll be able to eliminate negative thoughts by conditioning your mind to be more positive.",
|
| 217 |
+
label="Prompt Text",
|
| 218 |
+
placeholder="Please enter the prompt text. Automatic recognition is supported, and you can correct the results yourself..."
|
| 219 |
+
)
|
| 220 |
+
run_btn = gr.Button("Generate Speech", variant="primary")
|
| 221 |
+
|
| 222 |
+
with gr.Column():
|
| 223 |
+
cfg_value = gr.Slider(
|
| 224 |
+
minimum=1.0,
|
| 225 |
+
maximum=3.0,
|
| 226 |
+
value=2.0,
|
| 227 |
+
step=0.1,
|
| 228 |
+
label="CFG Value (Guidance Scale)",
|
| 229 |
+
info="Higher values increase adherence to prompt, lower values allow more creativity"
|
| 230 |
+
)
|
| 231 |
+
inference_timesteps = gr.Slider(
|
| 232 |
+
minimum=4,
|
| 233 |
+
maximum=30,
|
| 234 |
+
value=10,
|
| 235 |
+
step=1,
|
| 236 |
+
label="Inference Timesteps",
|
| 237 |
+
info="Number of inference timesteps for generation (higher values may improve quality but slower)"
|
| 238 |
+
)
|
| 239 |
+
with gr.Row():
|
| 240 |
+
text = gr.Textbox(
|
| 241 |
+
value="VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly realistic speech.",
|
| 242 |
+
label="Target Text",
|
| 243 |
+
)
|
| 244 |
+
with gr.Row():
|
| 245 |
+
DoNormalizeText = gr.Checkbox(
|
| 246 |
+
value=False,
|
| 247 |
+
label="Text Normalization",
|
| 248 |
+
elem_id="chk_normalize",
|
| 249 |
+
info="We use wetext library to normalize the input text."
|
| 250 |
+
)
|
| 251 |
+
audio_output = gr.Audio(label="Output Audio")
|
| 252 |
+
|
| 253 |
+
# Wiring
|
| 254 |
+
run_btn.click(
|
| 255 |
+
fn=demo.generate_tts_audio,
|
| 256 |
+
inputs=[text, prompt_wav, prompt_text, cfg_value, inference_timesteps, DoNormalizeText, DoDenoisePromptAudio],
|
| 257 |
+
outputs=[audio_output],
|
| 258 |
+
show_progress=True,
|
| 259 |
+
api_name="generate",
|
| 260 |
+
)
|
| 261 |
+
prompt_wav.change(fn=demo.prompt_wav_recognition, inputs=[prompt_wav], outputs=[prompt_text])
|
| 262 |
+
|
| 263 |
+
return interface
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
def run_demo(server_name: str = "localhost", server_port: int = 7860, show_error: bool = True):
|
| 267 |
+
demo = VoxCPMDemo()
|
| 268 |
+
interface = create_demo_interface(demo)
|
| 269 |
+
# Recommended to enable queue on Spaces for better throughput
|
| 270 |
+
interface.queue(max_size=10).launch(server_name=server_name, server_port=server_port, show_error=show_error)
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
if __name__ == "__main__":
|
| 274 |
+
run_demo()
|
VoxCPM/assets/modelbest_logo.png
ADDED
|
VoxCPM/assets/thuhcsi_logo.png
ADDED
|
VoxCPM/assets/voxcpm_logo.png
ADDED
|
VoxCPM/assets/voxcpm_model.png
ADDED
|
Git LFS Details
|
VoxCPM/assets/wechat.png
ADDED
|
VoxCPM/ckpts/.gitattributes
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
assets/voxcpm_model.png filter=lfs diff=lfs merge=lfs -text
|
VoxCPM/ckpts/README.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- zh
|
| 6 |
+
base_model:
|
| 7 |
+
- openbmb/MiniCPM4-0.5B
|
| 8 |
+
pipeline_tag: text-to-speech
|
| 9 |
+
library_name: voxcpm
|
| 10 |
+
tags:
|
| 11 |
+
- text-to-speech
|
| 12 |
+
- speech
|
| 13 |
+
- speech generation
|
| 14 |
+
- voice cloning
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## 🎙️ VoxCPM: Tokenizer-Free TTS for Context-Aware Speech Generation and True-to-Life Voice Cloning
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
[](https://github.com/OpenBMB/VoxCPM/) [](https://huggingface.co/openbmb/VoxCPM-0.5B) [](https://huggingface.co/spaces/OpenBMB/VoxCPM-Demo) [](https://openbmb.github.io/VoxCPM-demopage/)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
<div align="center">
|
| 24 |
+
<img src="assets/voxcpm_logo.png" alt="VoxCPM Logo" width="40%">
|
| 25 |
+
</div>
|
| 26 |
+
|
| 27 |
+
## Overview
|
| 28 |
+
|
| 29 |
+
VoxCPM is a novel tokenizer-free Text-to-Speech (TTS) system that redefines realism in speech synthesis. By modeling speech in a continuous space, it overcomes the limitations of discrete tokenization and enables two flagship capabilities: context-aware speech generation and true-to-life zero-shot voice cloning.
|
| 30 |
+
|
| 31 |
+
Unlike mainstream approaches that convert speech to discrete tokens, VoxCPM uses an end-to-end diffusion autoregressive architecture that directly generates continuous speech representations from text. Built on [MiniCPM-4](https://huggingface.co/openbmb/MiniCPM4-0.5B) backbone, it achieves implicit semantic-acoustic decoupling through hierachical language modeling and FSQ constraints, greatly enhancing both expressiveness and generation stability.
|
| 32 |
+
|
| 33 |
+
<div align="center">
|
| 34 |
+
<img src="assets/voxcpm_model.png" alt="VoxCPM Model Architecture" width="90%">
|
| 35 |
+
</div>
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
### 🚀 Key Features
|
| 39 |
+
- **Context-Aware, Expressive Speech Generation** - VoxCPM comprehends text to infer and generate appropriate prosody, delivering speech with remarkable expressiveness and natural flow. It spontaneously adapts speaking style based on content, producing highly fitting vocal expression trained on a massive 1.8 million-hour bilingual corpus.
|
| 40 |
+
- **True-to-Life Voice Cloning** - With only a short reference audio clip, VoxCPM performs accurate zero-shot voice cloning, capturing not only the speaker’s timbre but also fine-grained characteristics such as accent, emotional tone, rhythm, and pacing to create a faithful and natural replica.
|
| 41 |
+
- **High-Efficiency Synthesis** - VoxCPM supports streaming synthesis with a Real-Time Factor (RTF) as low as 0.17 on a consumer-grade NVIDIA RTX 4090 GPU, making it possible for real-time applications.
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
## Quick Start
|
| 45 |
+
|
| 46 |
+
### 🔧 Install from PyPI
|
| 47 |
+
``` sh
|
| 48 |
+
pip install voxcpm
|
| 49 |
+
```
|
| 50 |
+
### 1. Model Download (Optional)
|
| 51 |
+
By default, when you first run the script, the model will be downloaded automatically, but you can also download the model in advance.
|
| 52 |
+
- Download VoxCPM-0.5B
|
| 53 |
+
```
|
| 54 |
+
from huggingface_hub import snapshot_download
|
| 55 |
+
snapshot_download("openbmb/VoxCPM-0.5B",local_files_only=local_files_only)
|
| 56 |
+
```
|
| 57 |
+
- Download ZipEnhancer and SenseVoice-Small. We use ZipEnhancer to enhance speech prompts and SenseVoice-Small for speech prompt ASR in the web demo.
|
| 58 |
+
```
|
| 59 |
+
from modelscope import snapshot_download
|
| 60 |
+
snapshot_download('iic/speech_zipenhancer_ans_multiloss_16k_base')
|
| 61 |
+
snapshot_download('iic/SenseVoiceSmall')
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
### 2. Basic Usage
|
| 65 |
+
```python
|
| 66 |
+
import soundfile as sf
|
| 67 |
+
from voxcpm import VoxCPM
|
| 68 |
+
|
| 69 |
+
model = VoxCPM.from_pretrained("openbmb/VoxCPM-0.5B")
|
| 70 |
+
|
| 71 |
+
wav = model.generate(
|
| 72 |
+
text="VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech.",
|
| 73 |
+
prompt_wav_path=None, # optional: path to a prompt speech for voice cloning
|
| 74 |
+
prompt_text=None, # optional: reference text
|
| 75 |
+
cfg_value=2.0, # LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse
|
| 76 |
+
inference_timesteps=10, # LocDiT inference timesteps, higher for better result, lower for fast speed
|
| 77 |
+
normalize=True, # enable external TN tool
|
| 78 |
+
denoise=True, # enable external Denoise tool
|
| 79 |
+
retry_badcase=True, # enable retrying mode for some bad cases (unstoppable)
|
| 80 |
+
retry_badcase_max_times=3, # maximum retrying times
|
| 81 |
+
retry_badcase_ratio_threshold=6.0, # maximum length restriction for bad case detection (simple but effective), it could be adjusted for slow pace speech
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
sf.write("output.wav", wav, 16000)
|
| 85 |
+
print("saved: output.wav")
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
### 3. CLI Usage
|
| 89 |
+
|
| 90 |
+
After installation, the entry point is `voxcpm` (or use `python -m voxcpm.cli`).
|
| 91 |
+
|
| 92 |
+
```bash
|
| 93 |
+
# 1) Direct synthesis (single text)
|
| 94 |
+
voxcpm --text "Hello VoxCPM" --output out.wav
|
| 95 |
+
|
| 96 |
+
# 2) Voice cloning (reference audio + transcript)
|
| 97 |
+
voxcpm --text "Hello" \
|
| 98 |
+
--prompt-audio path/to/voice.wav \
|
| 99 |
+
--prompt-text "reference transcript" \
|
| 100 |
+
--output out.wav \
|
| 101 |
+
--denoise
|
| 102 |
+
|
| 103 |
+
# 3) Batch processing (one text per line)
|
| 104 |
+
voxcpm --input examples/input.txt --output-dir outs
|
| 105 |
+
# (optional) Batch + cloning
|
| 106 |
+
voxcpm --input examples/input.txt --output-dir outs \
|
| 107 |
+
--prompt-audio path/to/voice.wav \
|
| 108 |
+
--prompt-text "reference transcript" \
|
| 109 |
+
--denoise
|
| 110 |
+
|
| 111 |
+
# 4) Inference parameters (quality/speed)
|
| 112 |
+
voxcpm --text "..." --output out.wav \
|
| 113 |
+
--cfg-value 2.0 --inference-timesteps 10 --normalize
|
| 114 |
+
|
| 115 |
+
# 5) Model loading
|
| 116 |
+
# Prefer local path
|
| 117 |
+
voxcpm --text "..." --output out.wav --model-path /path/to/VoxCPM_model_dir
|
| 118 |
+
# Or from Hugging Face (auto download/cache)
|
| 119 |
+
voxcpm --text "..." --output out.wav \
|
| 120 |
+
--hf-model-id openbmb/VoxCPM-0.5B --cache-dir ~/.cache/huggingface --local-files-only
|
| 121 |
+
|
| 122 |
+
# 6) Denoiser control
|
| 123 |
+
voxcpm --text "..." --output out.wav \
|
| 124 |
+
--no-denoiser --zipenhancer-path iic/speech_zipenhancer_ans_multiloss_16k_base
|
| 125 |
+
|
| 126 |
+
# 7) Help
|
| 127 |
+
voxcpm --help
|
| 128 |
+
python -m voxcpm.cli --help
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
### 4. Start web demo
|
| 132 |
+
|
| 133 |
+
You can start the UI interface by running `python app.py`, which allows you to perform Voice Cloning and Voice Creation.
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
## 👩🍳 A Voice Chef's Guide
|
| 138 |
+
Welcome to the VoxCPM kitchen! Follow this recipe to cook up perfect generated speech. Let’s begin.
|
| 139 |
+
|
| 140 |
+
---
|
| 141 |
+
### 🥚 Step 1: Prepare Your Base Ingredients (Content)
|
| 142 |
+
|
| 143 |
+
First, choose how you’d like to input your text:.
|
| 144 |
+
1. Regular Text (Classic Mode)
|
| 145 |
+
- ✅ Keep "Text Normalization" ON. Type naturally (e.g., "Hello, world! 123"). The system will automatically process numbers, abbreviations, and punctuation using WeTextProcessing library.
|
| 146 |
+
2. Phoneme Input (Native Mode)
|
| 147 |
+
- ❌ Turn "Text Normalization" OFF. Enter phoneme text like {HH AH0 L OW1} (EN) or {ni3}{hao3} (ZH) for precise pronunciation control. In this mode, VoxCPM also supports native understanding of other complex non-normalized text—try it out!
|
| 148 |
+
|
| 149 |
+
---
|
| 150 |
+
### 🍳 Step 2: Choose Your Flavor Profile (Voice Style)
|
| 151 |
+
|
| 152 |
+
This is the secret sauce that gives your audio its unique sound.
|
| 153 |
+
1. Cooking with a Prompt Speech (Following a Famous Recipe)
|
| 154 |
+
- A prompt speech provides the desired acoustic characteristics for VoxCPM. The speaker's timbre, speaking style, and even the background sounds and ambiance will be replicated.
|
| 155 |
+
- For a Clean, Studio-Quality Voice:
|
| 156 |
+
- ✅ Enable "Prompt Speech Enhancement". This acts like a noise filter, removing background hiss and rumble to give you a pure, clean voice clone.
|
| 157 |
+
2. Cooking au Naturel (Letting the Model Improvise)
|
| 158 |
+
- If no reference is provided, VoxCPM becomes a creative chef! It will infer a fitting speaking style based on the text itself, thanks to the text-smartness of its foundation model, MiniCPM-4.
|
| 159 |
+
- Pro Tip: Challenge VoxCPM with any text—poetry, song lyrics, dramatic monologues—it may deliver some interesting results!
|
| 160 |
+
|
| 161 |
+
---
|
| 162 |
+
### 🧂 Step 3: The Final Seasoning (Fine-Tuning Your Results)
|
| 163 |
+
You're ready to serve! But for master chefs who want to tweak the flavor, here are two key spices.
|
| 164 |
+
- CFG Value (How Closely to Follow the Recipe)
|
| 165 |
+
- Default: A great starting point.
|
| 166 |
+
- Voice sounds strained or weird? Lower this value. It tells the model to be more relaxed and improvisational, great for expressive prompts.
|
| 167 |
+
- Need maximum clarity and adherence to the text? Raise it slightly to keep the model on a tighter leash.
|
| 168 |
+
- Inference Timesteps (Simmering Time: Quality vs. Speed)
|
| 169 |
+
- Need a quick snack? Use a lower number. Perfect for fast drafts and experiments.
|
| 170 |
+
- Cooking a gourmet meal? Use a higher number. This lets the model "simmer" longer, refining the audio for superior detail and naturalness.
|
| 171 |
+
|
| 172 |
+
---
|
| 173 |
+
Happy creating! 🎉 Start with the default settings and tweak from there to suit your project. The kitchen is yours!
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
---
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
## 📊 Performance Highlights
|
| 181 |
+
|
| 182 |
+
VoxCPM achieves competitive results on public zero-shot TTS benchmarks:
|
| 183 |
+
|
| 184 |
+
### Seed-TTS-eval Benchmark
|
| 185 |
+
|
| 186 |
+
| Model | Parameters | Open-Source | test-EN | | test-ZH | | test-Hard | |
|
| 187 |
+
|------|------|------|:------------:|:--:|:------------:|:--:|:-------------:|:--:|
|
| 188 |
+
| | | | WER/%⬇ | SIM/%⬆| CER/%⬇| SIM/%⬆ | CER/%⬇ | SIM/%⬆ |
|
| 189 |
+
| MegaTTS3 | 0.5B | ❌ | 2.79 | 77.1 | 1.52 | 79.0 | - | - |
|
| 190 |
+
| DiTAR | 0.6B | ❌ | 1.69 | 73.5 | 1.02 | 75.3 | - | - |
|
| 191 |
+
| CosyVoice3 | 0.5B | ❌ | 2.02 | 71.8 | 1.16 | 78.0 | 6.08 | 75.8 |
|
| 192 |
+
| CosyVoice3 | 1.5B | ❌ | 2.22 | 72.0 | 1.12 | 78.1 | 5.83 | 75.8 |
|
| 193 |
+
| Seed-TTS | - | ❌ | 2.25 | 76.2 | 1.12 | 79.6 | 7.59 | 77.6 |
|
| 194 |
+
| MiniMax-Speech | - | ❌ | 1.65 | 69.2 | 0.83 | 78.3 | - | - |
|
| 195 |
+
| CosyVoice | 0.3B | ✅ | 4.29 | 60.9 | 3.63 | 72.3 | 11.75 | 70.9 |
|
| 196 |
+
| CosyVoice2 | 0.5B | ✅ | 3.09 | 65.9 | 1.38 | 75.7 | **6.83** | 72.4 |
|
| 197 |
+
| F5-TTS | 0.3B | ✅ | 2.00 | 67.0 | 1.53 | 76.0 | 8.67 | 71.3 |
|
| 198 |
+
| SparkTTS | 0.5B | ✅ | 3.14 | 57.3 | 1.54 | 66.0 | - | - |
|
| 199 |
+
| FireRedTTS | 0.5B | ✅ | 3.82 | 46.0 | 1.51 | 63.5 | 17.45 | 62.1 |
|
| 200 |
+
| FireRedTTS-2 | 1.5B | ✅ | 1.95 | 66.5 | 1.14 | 73.6 | - | - |
|
| 201 |
+
| Qwen2.5-Omni | 7B | ✅ | 2.72 | 63.2 | 1.70 | 75.2 | 7.97 | **74.7** |
|
| 202 |
+
| OpenAudio-s1-mini | 0.5B | ✅ | 1.94 | 55.0 | 1.18 | 68.5 | - | - |
|
| 203 |
+
| IndexTTS2 | 1.5B | ✅ | 2.23 | 70.6 | 1.03 | 76.5 | - | - |
|
| 204 |
+
| VibeVoice | 1.5B | ✅ | 3.04 | 68.9 | 1.16 | 74.4 | - | - |
|
| 205 |
+
| HiggsAudio-v2 | 3B | ✅ | 2.44 | 67.7 | 1.50 | 74.0 | - | - |
|
| 206 |
+
| **VoxCPM** | 0.5B | ✅ | **1.85** | **72.9** | **0.93** | **77.2** | 8.87 | 73.0 |
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
### CV3-eval Benchmark
|
| 210 |
+
|
| 211 |
+
| Model | zh | en | hard-zh | | | hard-en | | |
|
| 212 |
+
|-------|:--:|:--:|:-------:|:--:|:--:|:-------:|:--:|:--:|
|
| 213 |
+
| | CER/%⬇ | WER/%⬇ | CER/%⬇ | SIM/%⬆ | DNSMOS⬆ | WER/%⬇ | SIM/%⬆ | DNSMOS⬆ |
|
| 214 |
+
| F5-TTS | 5.47 | 8.90 | - | - | - | - | - | - |
|
| 215 |
+
| SparkTTS | 5.15 | 11.0 | - | - | - | - | - | - |
|
| 216 |
+
| GPT-SoVits | 7.34 | 12.5 | - | - | - | - | - | - |
|
| 217 |
+
| CosyVoice2 | 4.08 | 6.32 | 12.58 | 72.6 | 3.81 | 11.96 | 66.7 | 3.95 |
|
| 218 |
+
| OpenAudio-s1-mini | 4.00 | 5.54 | 18.1 | 58.2 | 3.77 | 12.4 | 55.7 | 3.89 |
|
| 219 |
+
| IndexTTS2 | 3.58 | 4.45 | 12.8 | 74.6 | 3.65 | - | - | - |
|
| 220 |
+
| HiggsAudio-v2 | 9.54 | 7.89 | 41.0 | 60.2 | 3.39 | 10.3 | 61.8 | 3.68 |
|
| 221 |
+
| CosyVoice3-0.5B | 3.89 | 5.24 | 14.15 | 78.6 | 3.75 | 9.04 | 75.9 | 3.92 |
|
| 222 |
+
| CosyVoice3-1.5B | 3.91 | 4.99 | 9.77 | 78.5 | 3.79 | 10.55 | 76.1 | 3.95 |
|
| 223 |
+
| **VoxCPM** | **3.40** | **4.04** | 12.9 | 66.1 | 3.59 | **7.89** | 64.3 | 3.74 |
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
## ⚠️ Risks and limitations
|
| 227 |
+
- General Model Behavior: While VoxCPM has been trained on a large-scale dataset, it may still produce outputs that are unexpected, biased, or contain artifacts.
|
| 228 |
+
- Potential for Misuse of Voice Cloning: VoxCPM's powerful zero-shot voice cloning capability can generate highly realistic synthetic speech. This technology could be misused for creating convincing deepfakes for purposes of impersonation, fraud, or spreading disinformation. Users of this model must not use it to create content that infringes upon the rights of individuals. It is strictly forbidden to use VoxCPM for any illegal or unethical purposes. We strongly recommend that any publicly shared content generated with this model be clearly marked as AI-generated.
|
| 229 |
+
- Current Technical Limitations: Although generally stable, the model may occasionally exhibit instability, especially with very long or expressive inputs. Furthermore, the current version offers limited direct control over specific speech attributes like emotion or speaking style.
|
| 230 |
+
- Bilingual Model: VoxCPM is trained primarily on Chinese and English data. Performance on other languages is not guaranteed and may result in unpredictable or low-quality audio.
|
| 231 |
+
- This model is released for research and development purposes only. We do not recommend its use in production or commercial applications without rigorous testing and safety evaluations. Please use VoxCPM responsibly.
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
## 📄 License
|
| 236 |
+
The VoxCPM model weights and code are open-sourced under the Apache-2.0 license.
|
| 237 |
+
|
| 238 |
+
|
VoxCPM/ckpts/assets/modelbest_logo.png
ADDED
|
VoxCPM/ckpts/assets/thuhcsi_logo.png
ADDED
|
VoxCPM/ckpts/assets/voxcpm_logo.png
ADDED
|
VoxCPM/ckpts/assets/voxcpm_model.png
ADDED
|
Git LFS Details
|
VoxCPM/ckpts/audiovae.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5b93f34c771281679b0ff93be3d1c1681eb1f301c3892e701db8f10a725b20a9
|
| 3 |
+
size 301494192
|
VoxCPM/ckpts/config.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture": "voxcpm",
|
| 3 |
+
"lm_config": {
|
| 4 |
+
"bos_token_id": 1,
|
| 5 |
+
"eos_token_id": 2,
|
| 6 |
+
"hidden_size": 1024,
|
| 7 |
+
"intermediate_size": 4096,
|
| 8 |
+
"max_position_embeddings": 32768,
|
| 9 |
+
"num_attention_heads": 16,
|
| 10 |
+
"num_hidden_layers": 24,
|
| 11 |
+
"num_key_value_heads": 2,
|
| 12 |
+
"rms_norm_eps": 1e-05,
|
| 13 |
+
"rope_theta": 10000,
|
| 14 |
+
"rope_scaling": {
|
| 15 |
+
"type": "longrope",
|
| 16 |
+
"long_factor": [1.0004360675811768, 1.0668443441390991, 1.1631425619125366, 1.3025742769241333, 1.5040205717086792, 1.7941505908966064, 2.2101221084594727, 2.802666664123535, 3.6389970779418945, 4.804192543029785, 6.39855432510376, 8.527148246765137, 11.277542114257812, 14.684998512268066, 18.69317054748535, 23.13019371032715, 27.72362518310547, 32.1606559753418, 36.168827056884766, 39.57627868652344, 42.32667541503906, 44.45526885986328, 46.04962921142578, 47.21482849121094, 48.05115509033203, 48.64370346069336, 49.05967712402344, 49.34980392456055, 49.551246643066406, 49.69068145751953, 49.78697967529297, 49.85338592529297],
|
| 17 |
+
"short_factor": [1.0004360675811768, 1.0668443441390991, 1.1631425619125366, 1.3025742769241333, 1.5040205717086792, 1.7941505908966064, 2.2101221084594727, 2.802666664123535, 3.6389970779418945, 4.804192543029785, 6.39855432510376, 8.527148246765137, 11.277542114257812, 14.684998512268066, 18.69317054748535, 23.13019371032715, 27.72362518310547, 32.1606559753418, 36.168827056884766, 39.57627868652344, 42.32667541503906, 44.45526885986328, 46.04962921142578, 47.21482849121094, 48.05115509033203, 48.64370346069336, 49.05967712402344, 49.34980392456055, 49.551246643066406, 49.69068145751953, 49.78697967529297, 49.85338592529297],
|
| 18 |
+
"original_max_position_embeddings": 32768
|
| 19 |
+
},
|
| 20 |
+
"vocab_size": 73448,
|
| 21 |
+
"scale_emb": 12,
|
| 22 |
+
"dim_model_base": 256,
|
| 23 |
+
"scale_depth": 1.4,
|
| 24 |
+
"use_mup": false
|
| 25 |
+
},
|
| 26 |
+
"patch_size": 2,
|
| 27 |
+
"feat_dim": 64,
|
| 28 |
+
"scalar_quantization_latent_dim": 256,
|
| 29 |
+
"scalar_quantization_scale": 9,
|
| 30 |
+
"residual_lm_num_layers": 6,
|
| 31 |
+
"encoder_config": {
|
| 32 |
+
"hidden_dim": 1024,
|
| 33 |
+
"ffn_dim": 4096,
|
| 34 |
+
"num_heads": 16,
|
| 35 |
+
"num_layers": 4
|
| 36 |
+
},
|
| 37 |
+
"dit_config": {
|
| 38 |
+
"hidden_dim": 1024,
|
| 39 |
+
"ffn_dim": 4096,
|
| 40 |
+
"num_heads": 16,
|
| 41 |
+
"num_layers": 4,
|
| 42 |
+
"cfm_config": {
|
| 43 |
+
"sigma_min": 1e-06,
|
| 44 |
+
"solver": "euler",
|
| 45 |
+
"t_scheduler": "log-norm",
|
| 46 |
+
"inference_cfg_rate": 2.0
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"max_length": 4096,
|
| 50 |
+
"device": "cuda",
|
| 51 |
+
"dtype": "bfloat16"
|
| 52 |
+
}
|
VoxCPM/ckpts/pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5bd0581582d410d35a41ec991dd78c774134ee7c18d74d6e99707ceae5f3566f
|
| 3 |
+
size 1304698606
|
VoxCPM/ckpts/special_tokens_map.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
{
|
| 4 |
+
"content": "<|im_end|>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
"content": "<|im_start|>",
|
| 12 |
+
"lstrip": false,
|
| 13 |
+
"normalized": false,
|
| 14 |
+
"rstrip": false,
|
| 15 |
+
"single_word": false
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"content": "<|tool_call|>",
|
| 19 |
+
"lstrip": false,
|
| 20 |
+
"normalized": false,
|
| 21 |
+
"rstrip": false,
|
| 22 |
+
"single_word": false
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"content": "<|execute_start|>",
|
| 26 |
+
"lstrip": false,
|
| 27 |
+
"normalized": false,
|
| 28 |
+
"rstrip": false,
|
| 29 |
+
"single_word": false
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"content": "<|execute_end|>",
|
| 33 |
+
"lstrip": false,
|
| 34 |
+
"normalized": false,
|
| 35 |
+
"rstrip": false,
|
| 36 |
+
"single_word": false
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"content": "<|fim_prefix|>",
|
| 40 |
+
"lstrip": false,
|
| 41 |
+
"normalized": false,
|
| 42 |
+
"rstrip": false,
|
| 43 |
+
"single_word": false
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"content": "<|fim_middle|>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"content": "<|fim_suffix|>",
|
| 54 |
+
"lstrip": false,
|
| 55 |
+
"normalized": false,
|
| 56 |
+
"rstrip": false,
|
| 57 |
+
"single_word": false
|
| 58 |
+
}
|
| 59 |
+
],
|
| 60 |
+
"bos_token": {
|
| 61 |
+
"content": "<s>",
|
| 62 |
+
"lstrip": false,
|
| 63 |
+
"normalized": false,
|
| 64 |
+
"rstrip": false,
|
| 65 |
+
"single_word": false
|
| 66 |
+
},
|
| 67 |
+
"eos_token": {
|
| 68 |
+
"content": "</s>",
|
| 69 |
+
"lstrip": false,
|
| 70 |
+
"normalized": false,
|
| 71 |
+
"rstrip": false,
|
| 72 |
+
"single_word": false
|
| 73 |
+
},
|
| 74 |
+
"unk_token": {
|
| 75 |
+
"content": "<unk>",
|
| 76 |
+
"lstrip": false,
|
| 77 |
+
"normalized": false,
|
| 78 |
+
"rstrip": false,
|
| 79 |
+
"single_word": false
|
| 80 |
+
}
|
| 81 |
+
}
|
VoxCPM/ckpts/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
VoxCPM/ckpts/tokenizer_config.json
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": true,
|
| 3 |
+
"add_eos_token": false,
|
| 4 |
+
"added_tokens_decoder": {
|
| 5 |
+
"0": {
|
| 6 |
+
"content": "<unk>",
|
| 7 |
+
"lstrip": false,
|
| 8 |
+
"normalized": false,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false,
|
| 11 |
+
"special": true
|
| 12 |
+
},
|
| 13 |
+
"1": {
|
| 14 |
+
"content": "<s>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"special": true
|
| 20 |
+
},
|
| 21 |
+
"2": {
|
| 22 |
+
"content": "</s>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": false,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": false,
|
| 27 |
+
"special": true
|
| 28 |
+
},
|
| 29 |
+
"101": {
|
| 30 |
+
"content": "<|audio_start|>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
},
|
| 37 |
+
"102": {
|
| 38 |
+
"content": "<|audio_end|>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false,
|
| 43 |
+
"special": true
|
| 44 |
+
},
|
| 45 |
+
"103": {
|
| 46 |
+
"content": "<|audio_prompt_start|>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false,
|
| 51 |
+
"special": true
|
| 52 |
+
},
|
| 53 |
+
"104": {
|
| 54 |
+
"content": "<|audio_prompt_end|>",
|
| 55 |
+
"lstrip": false,
|
| 56 |
+
"normalized": false,
|
| 57 |
+
"rstrip": false,
|
| 58 |
+
"single_word": false,
|
| 59 |
+
"special": true
|
| 60 |
+
},
|
| 61 |
+
"105": {
|
| 62 |
+
"content": "<|background|>",
|
| 63 |
+
"lstrip": false,
|
| 64 |
+
"normalized": false,
|
| 65 |
+
"rstrip": false,
|
| 66 |
+
"single_word": false,
|
| 67 |
+
"special": true
|
| 68 |
+
},
|
| 69 |
+
"106": {
|
| 70 |
+
"content": "<|/background|>",
|
| 71 |
+
"lstrip": false,
|
| 72 |
+
"normalized": false,
|
| 73 |
+
"rstrip": false,
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"special": true
|
| 76 |
+
},
|
| 77 |
+
"107": {
|
| 78 |
+
"content": "<|characters|>",
|
| 79 |
+
"lstrip": false,
|
| 80 |
+
"normalized": false,
|
| 81 |
+
"rstrip": false,
|
| 82 |
+
"single_word": false,
|
| 83 |
+
"special": true
|
| 84 |
+
},
|
| 85 |
+
"108": {
|
| 86 |
+
"content": "<|/characters|>",
|
| 87 |
+
"lstrip": false,
|
| 88 |
+
"normalized": false,
|
| 89 |
+
"rstrip": false,
|
| 90 |
+
"single_word": false,
|
| 91 |
+
"special": true
|
| 92 |
+
},
|
| 93 |
+
"109": {
|
| 94 |
+
"content": "<|speaker_id|>",
|
| 95 |
+
"lstrip": false,
|
| 96 |
+
"normalized": false,
|
| 97 |
+
"rstrip": false,
|
| 98 |
+
"single_word": false,
|
| 99 |
+
"special": true
|
| 100 |
+
},
|
| 101 |
+
"110": {
|
| 102 |
+
"content": "<|/speaker_id|>",
|
| 103 |
+
"lstrip": false,
|
| 104 |
+
"normalized": false,
|
| 105 |
+
"rstrip": false,
|
| 106 |
+
"single_word": false,
|
| 107 |
+
"special": true
|
| 108 |
+
},
|
| 109 |
+
"111": {
|
| 110 |
+
"content": "<|span|>",
|
| 111 |
+
"lstrip": false,
|
| 112 |
+
"normalized": false,
|
| 113 |
+
"rstrip": false,
|
| 114 |
+
"single_word": false,
|
| 115 |
+
"special": true
|
| 116 |
+
},
|
| 117 |
+
"112": {
|
| 118 |
+
"content": "<|/span|>",
|
| 119 |
+
"lstrip": false,
|
| 120 |
+
"normalized": false,
|
| 121 |
+
"rstrip": false,
|
| 122 |
+
"single_word": false,
|
| 123 |
+
"special": true
|
| 124 |
+
},
|
| 125 |
+
"73440": {
|
| 126 |
+
"content": "<|im_end|>",
|
| 127 |
+
"lstrip": false,
|
| 128 |
+
"normalized": false,
|
| 129 |
+
"rstrip": false,
|
| 130 |
+
"single_word": false,
|
| 131 |
+
"special": true
|
| 132 |
+
},
|
| 133 |
+
"73441": {
|
| 134 |
+
"content": "<|im_start|>",
|
| 135 |
+
"lstrip": false,
|
| 136 |
+
"normalized": false,
|
| 137 |
+
"rstrip": false,
|
| 138 |
+
"single_word": false,
|
| 139 |
+
"special": true
|
| 140 |
+
},
|
| 141 |
+
"73442": {
|
| 142 |
+
"content": "<|tool_call|>",
|
| 143 |
+
"lstrip": false,
|
| 144 |
+
"normalized": false,
|
| 145 |
+
"rstrip": false,
|
| 146 |
+
"single_word": false,
|
| 147 |
+
"special": true
|
| 148 |
+
},
|
| 149 |
+
"73443": {
|
| 150 |
+
"content": "<|execute_start|>",
|
| 151 |
+
"lstrip": false,
|
| 152 |
+
"normalized": false,
|
| 153 |
+
"rstrip": false,
|
| 154 |
+
"single_word": false,
|
| 155 |
+
"special": true
|
| 156 |
+
},
|
| 157 |
+
"73444": {
|
| 158 |
+
"content": "<|execute_end|>",
|
| 159 |
+
"lstrip": false,
|
| 160 |
+
"normalized": false,
|
| 161 |
+
"rstrip": false,
|
| 162 |
+
"single_word": false,
|
| 163 |
+
"special": true
|
| 164 |
+
},
|
| 165 |
+
"73445": {
|
| 166 |
+
"content": "<|fim_prefix|>",
|
| 167 |
+
"lstrip": false,
|
| 168 |
+
"normalized": false,
|
| 169 |
+
"rstrip": false,
|
| 170 |
+
"single_word": false,
|
| 171 |
+
"special": true
|
| 172 |
+
},
|
| 173 |
+
"73446": {
|
| 174 |
+
"content": "<|fim_middle|>",
|
| 175 |
+
"lstrip": false,
|
| 176 |
+
"normalized": false,
|
| 177 |
+
"rstrip": false,
|
| 178 |
+
"single_word": false,
|
| 179 |
+
"special": true
|
| 180 |
+
},
|
| 181 |
+
"73447": {
|
| 182 |
+
"content": "<|fim_suffix|>",
|
| 183 |
+
"lstrip": false,
|
| 184 |
+
"normalized": false,
|
| 185 |
+
"rstrip": false,
|
| 186 |
+
"single_word": false,
|
| 187 |
+
"special": true
|
| 188 |
+
}
|
| 189 |
+
},
|
| 190 |
+
"additional_special_tokens": [
|
| 191 |
+
"<|im_end|>",
|
| 192 |
+
"<|im_start|>",
|
| 193 |
+
"<|tool_call|>",
|
| 194 |
+
"<|execute_start|>",
|
| 195 |
+
"<|execute_end|>",
|
| 196 |
+
"<|fim_prefix|>",
|
| 197 |
+
"<|fim_middle|>",
|
| 198 |
+
"<|fim_suffix|>"
|
| 199 |
+
],
|
| 200 |
+
"bos_token": "<s>",
|
| 201 |
+
"clean_up_tokenization_spaces": false,
|
| 202 |
+
"eos_token": "<|im_end|>",
|
| 203 |
+
"legacy": true,
|
| 204 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 205 |
+
"pad_token": null,
|
| 206 |
+
"sp_model_kwargs": {},
|
| 207 |
+
"spaces_between_special_tokens": false,
|
| 208 |
+
"tokenizer_class": "LlamaTokenizer",
|
| 209 |
+
"unk_token": "<unk>",
|
| 210 |
+
"use_default_system_prompt": false,
|
| 211 |
+
"chat_template": "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}"
|
| 212 |
+
}
|
VoxCPM/conf/voxcpm/experiments/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LoRA 实验对照组
|
| 2 |
+
|
| 3 |
+
## 实验目的
|
| 4 |
+
探索不同 LoRA 配置对 VoxCPM 微调效果的影响,找出最佳配置。
|
| 5 |
+
|
| 6 |
+
## 已知结论
|
| 7 |
+
- **仅 DiT LoRA + 小 scaling (0.5)**: ✅ Work
|
| 8 |
+
- **LM + DiT LoRA + 大 scaling (2.0)**: ❌ 噪声
|
| 9 |
+
|
| 10 |
+
## 实验列表
|
| 11 |
+
|
| 12 |
+
| 实验 | enable_lm | enable_dit | r | alpha | scaling | target_modules | 预期 |
|
| 13 |
+
|------|-----------|------------|---|-------|---------|----------------|------|
|
| 14 |
+
| exp_01 | ❌ | ✅ | 32 | 16 | 0.5 | DiT: qkvo | ✅ Work (已验证) |
|
| 15 |
+
| exp_02 | ❌ | ✅ | 32 | 32 | 1.0 | DiT: qkvo | 可能 Work |
|
| 16 |
+
| exp_03 | ❌ | ✅ | 32 | 64 | 2.0 | DiT: qkvo | 风险较高 |
|
| 17 |
+
| exp_04 | ✅ | ❌ | 32 | 16 | 0.5 | LM: qkvo | 可能不 Work |
|
| 18 |
+
| exp_05 | ✅ | ❌ | 32 | 8 | 0.25 | LM: qkvo | 边界测试 |
|
| 19 |
+
| exp_06 | ✅ | ✅ | 32 | 16 | 0.5 | LM+DiT: qkvo | 可能不 Work |
|
| 20 |
+
| exp_07 | ✅ | ✅ | 32 | 8 | 0.25 | LM+DiT: qkvo | 边界测试 |
|
| 21 |
+
| exp_08 | ❌ | ✅ | 8 | 8 | 1.0 | DiT: qkvo | 小 rank 测试 |
|
| 22 |
+
| exp_09 | ❌ | ✅ | 64 | 64 | 1.0 | DiT: qkvo | 大 rank 测试 |
|
| 23 |
+
| exp_10 | ❌ | ✅ | 32 | 16 | 0.5 | DiT: qkvo+mlp | 更多模块测试 |
|
| 24 |
+
|
| 25 |
+
## 运行命令
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
# 训练
|
| 29 |
+
CUDA_VISIBLE_DEVICES=0 python scripts/train_voxcpm_finetune.py \
|
| 30 |
+
--config_path conf/voxcpm/experiments/exp_XX.yaml
|
| 31 |
+
|
| 32 |
+
# 推理测试
|
| 33 |
+
python scripts/test_voxcpm_lora_infer.py \
|
| 34 |
+
--config_path conf/voxcpm/experiments/exp_XX.yaml \
|
| 35 |
+
--lora_ckpt /user/liuxin/checkpoints/voxcpm_exp/exp_XX/step_0005000 \
|
| 36 |
+
--text "你好,这是一个测试。" \
|
| 37 |
+
--output exp_XX_test.wav
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
## 评估指标
|
| 41 |
+
1. **能否正常说话**: 生成的音频是否有人声(而非噪声)
|
| 42 |
+
2. **能否正常停止**: 是否在合理的时间内停止(而非跑满 max_len)
|
| 43 |
+
3. **音色相似度**: 与训练数据的音色是否相似(主观评估)
|
| 44 |
+
4. **Loss 收敛**: 训练过程中 loss/diff 和 loss/stop 的收敛情况
|
| 45 |
+
|
| 46 |
+
## 结果记录
|
| 47 |
+
|
| 48 |
+
| 实验 | 能说话 | 能停止 | 音色相似度 | 备注 |
|
| 49 |
+
|------|--------|--------|------------|------|
|
| 50 |
+
| exp_01 | ✅ | ✅ | | |
|
| 51 |
+
| exp_02 | ✅ | ✅ | | |
|
| 52 |
+
| exp_03 | | | | |
|
| 53 |
+
| exp_04 | | | | |
|
| 54 |
+
| exp_05 | | | | |
|
| 55 |
+
| exp_06 | | | | |
|
| 56 |
+
| exp_07 | | | | |
|
| 57 |
+
| exp_08 | | | | |
|
| 58 |
+
| exp_09 | | | | |
|
| 59 |
+
| exp_10 | | | | |
|
| 60 |
+
|
VoxCPM/conf/voxcpm/experiments/exp_01_dit_only_scale05.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 实验 01: 仅 DiT LoRA, scaling=0.5 (r=32, alpha=16)
|
| 2 |
+
# 预期: 应该 work(你已验证)
|
| 3 |
+
pretrained_path: /user/zhouyixuan/ckpt/VoxCPM-0.5B-20250912-decay/
|
| 4 |
+
train_manifest: /user/liuxin/workspace/data/mianduan/1104-miantuan-data/metadata.jsonl
|
| 5 |
+
val_manifest: null
|
| 6 |
+
sample_rate: 16000
|
| 7 |
+
batch_size: 16
|
| 8 |
+
grad_accum_steps: 1
|
| 9 |
+
num_workers: 2
|
| 10 |
+
num_iters: 2000
|
| 11 |
+
log_interval: 10
|
| 12 |
+
valid_interval: 500
|
| 13 |
+
save_interval: 500
|
| 14 |
+
learning_rate: 0.0002
|
| 15 |
+
weight_decay: 0.01
|
| 16 |
+
warmup_steps: 200
|
| 17 |
+
max_steps: 2000
|
| 18 |
+
max_batch_tokens: 8192
|
| 19 |
+
save_path: /user/liuxin/checkpoints/voxcpm_exp/exp_01_dit_only_scale05
|
| 20 |
+
tensorboard: /user/liuxin/checkpoints/logs/exp_01
|
| 21 |
+
lambdas:
|
| 22 |
+
loss/diff: 1.0
|
| 23 |
+
loss/stop: 1.0
|
| 24 |
+
lora:
|
| 25 |
+
enable_lm: false
|
| 26 |
+
enable_dit: true
|
| 27 |
+
enable_proj: false
|
| 28 |
+
r: 32
|
| 29 |
+
alpha: 16 # scaling = 16/32 = 0.5
|
| 30 |
+
dropout: 0.0
|
| 31 |
+
target_modules_lm: []
|
| 32 |
+
target_modules_dit: ["q_proj", "v_proj", "k_proj", "o_proj"]
|
| 33 |
+
|
VoxCPM/conf/voxcpm/experiments/exp_02_dit_only_scale10.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 实验 02: 仅 DiT LoRA, scaling=1.0 (r=32, alpha=32)
|
| 2 |
+
# 预期: 可能 work,比 0.5 更强的适应能力
|
| 3 |
+
pretrained_path: /user/zhouyixuan/ckpt/VoxCPM-0.5B-20250912-decay/
|
| 4 |
+
train_manifest: /user/liuxin/workspace/data/mianduan/1104-miantuan-data/metadata.jsonl
|
| 5 |
+
val_manifest: null
|
| 6 |
+
sample_rate: 16000
|
| 7 |
+
batch_size: 16
|
| 8 |
+
grad_accum_steps: 1
|
| 9 |
+
num_workers: 2
|
| 10 |
+
num_iters: 2000
|
| 11 |
+
log_interval: 10
|
| 12 |
+
valid_interval: 500
|
| 13 |
+
save_interval: 500
|
| 14 |
+
learning_rate: 0.0002
|
| 15 |
+
weight_decay: 0.01
|
| 16 |
+
warmup_steps: 200
|
| 17 |
+
max_steps: 2000
|
| 18 |
+
max_batch_tokens: 8192
|
| 19 |
+
save_path: /user/liuxin/checkpoints/voxcpm_exp/exp_02_dit_only_scale10
|
| 20 |
+
tensorboard: /user/liuxin/checkpoints/logs/exp_02
|
| 21 |
+
lambdas:
|
| 22 |
+
loss/diff: 1.0
|
| 23 |
+
loss/stop: 1.0
|
| 24 |
+
lora:
|
| 25 |
+
enable_lm: false
|
| 26 |
+
enable_dit: true
|
| 27 |
+
enable_proj: false
|
| 28 |
+
r: 32
|
| 29 |
+
alpha: 32 # scaling = 32/32 = 1.0
|
| 30 |
+
dropout: 0.0
|
| 31 |
+
target_modules_lm: []
|
| 32 |
+
target_modules_dit: ["q_proj", "v_proj", "k_proj", "o_proj"]
|
| 33 |
+
|
VoxCPM/conf/voxcpm/experiments/exp_03_dit_only_scale20.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 实验 03: 仅 DiT LoRA, scaling=2.0 (r=32, alpha=64)
|
| 2 |
+
# 预期: 可能 work,但风险较高(scaling 较大)
|
| 3 |
+
pretrained_path: /user/zhouyixuan/ckpt/VoxCPM-0.5B-20250912-decay/
|
| 4 |
+
train_manifest: /user/liuxin/workspace/data/mianduan/1104-miantuan-data/metadata.jsonl
|
| 5 |
+
val_manifest: null
|
| 6 |
+
sample_rate: 16000
|
| 7 |
+
batch_size: 16
|
| 8 |
+
grad_accum_steps: 1
|
| 9 |
+
num_workers: 2
|
| 10 |
+
num_iters: 2000
|
| 11 |
+
log_interval: 10
|
| 12 |
+
valid_interval: 500
|
| 13 |
+
save_interval: 500
|
| 14 |
+
learning_rate: 0.0002
|
| 15 |
+
weight_decay: 0.01
|
| 16 |
+
warmup_steps: 200
|
| 17 |
+
max_steps: 2000
|
| 18 |
+
max_batch_tokens: 8192
|
| 19 |
+
save_path: /user/liuxin/checkpoints/voxcpm_exp/exp_03_dit_only_scale20
|
| 20 |
+
tensorboard: /user/liuxin/checkpoints/logs/exp_03
|
| 21 |
+
lambdas:
|
| 22 |
+
loss/diff: 1.0
|
| 23 |
+
loss/stop: 1.0
|
| 24 |
+
lora:
|
| 25 |
+
enable_lm: false
|
| 26 |
+
enable_dit: true
|
| 27 |
+
enable_proj: false
|
| 28 |
+
r: 32
|
| 29 |
+
alpha: 64 # scaling = 64/32 = 2.0
|
| 30 |
+
dropout: 0.0
|
| 31 |
+
target_modules_lm: []
|
| 32 |
+
target_modules_dit: ["q_proj", "v_proj", "k_proj", "o_proj"]
|
| 33 |
+
|
VoxCPM/conf/voxcpm/experiments/exp_04_lm_only_scale05.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 实验 04: 仅 LM LoRA, scaling=0.5 (r=32, alpha=16)
|
| 2 |
+
# 预期: 可能不 work(LM 改变会影响 stop predictor)
|
| 3 |
+
pretrained_path: /user/zhouyixuan/ckpt/VoxCPM-0.5B-20250912-decay/
|
| 4 |
+
train_manifest: /user/liuxin/workspace/data/mianduan/1104-miantuan-data/metadata.jsonl
|
| 5 |
+
val_manifest: null
|
| 6 |
+
sample_rate: 16000
|
| 7 |
+
batch_size: 16
|
| 8 |
+
grad_accum_steps: 1
|
| 9 |
+
num_workers: 2
|
| 10 |
+
num_iters: 2000
|
| 11 |
+
log_interval: 10
|
| 12 |
+
valid_interval: 500
|
| 13 |
+
save_interval: 500
|
| 14 |
+
learning_rate: 0.0002
|
| 15 |
+
weight_decay: 0.01
|
| 16 |
+
warmup_steps: 200
|
| 17 |
+
max_steps: 2000
|
| 18 |
+
max_batch_tokens: 8192
|
| 19 |
+
save_path: /user/liuxin/checkpoints/voxcpm_exp/exp_04_lm_only_scale05
|
| 20 |
+
tensorboard: /user/liuxin/checkpoints/logs/exp_04
|
| 21 |
+
lambdas:
|
| 22 |
+
loss/diff: 1.0
|
| 23 |
+
loss/stop: 1.0
|
| 24 |
+
lora:
|
| 25 |
+
enable_lm: true
|
| 26 |
+
enable_dit: false
|
| 27 |
+
enable_proj: false
|
| 28 |
+
r: 32
|
| 29 |
+
alpha: 16 # scaling = 16/32 = 0.5
|
| 30 |
+
dropout: 0.0
|
| 31 |
+
target_modules_lm: ["q_proj", "v_proj", "k_proj", "o_proj"] # 仅 attention
|
| 32 |
+
target_modules_dit: []
|
| 33 |
+
|
VoxCPM/conf/voxcpm/experiments/exp_05_lm_only_scale025.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 实验 05: 仅 LM LoRA, scaling=0.25 (r=32, alpha=8)
|
| 2 |
+
# 预期: 可能 work(极小的 scaling 可能不会破坏 stop predictor)
|
| 3 |
+
pretrained_path: /user/zhouyixuan/ckpt/VoxCPM-0.5B-20250912-decay/
|
| 4 |
+
train_manifest: /user/liuxin/workspace/data/mianduan/1104-miantuan-data/metadata.jsonl
|
| 5 |
+
val_manifest: null
|
| 6 |
+
sample_rate: 16000
|
| 7 |
+
batch_size: 16
|
| 8 |
+
grad_accum_steps: 1
|
| 9 |
+
num_workers: 2
|
| 10 |
+
num_iters: 2000
|
| 11 |
+
log_interval: 10
|
| 12 |
+
valid_interval: 500
|
| 13 |
+
save_interval: 500
|
| 14 |
+
learning_rate: 0.0002
|
| 15 |
+
weight_decay: 0.01
|
| 16 |
+
warmup_steps: 200
|
| 17 |
+
max_steps: 2000
|
| 18 |
+
max_batch_tokens: 8192
|
| 19 |
+
save_path: /user/liuxin/checkpoints/voxcpm_exp/exp_05_lm_only_scale025
|
| 20 |
+
tensorboard: /user/liuxin/checkpoints/logs/exp_05
|
| 21 |
+
lambdas:
|
| 22 |
+
loss/diff: 1.0
|
| 23 |
+
loss/stop: 1.0
|
| 24 |
+
lora:
|
| 25 |
+
enable_lm: true
|
| 26 |
+
enable_dit: false
|
| 27 |
+
enable_proj: false
|
| 28 |
+
r: 32
|
| 29 |
+
alpha: 8 # scaling = 8/32 = 0.25
|
| 30 |
+
dropout: 0.0
|
| 31 |
+
target_modules_lm: ["q_proj", "v_proj", "k_proj", "o_proj"] # 仅 attention
|
| 32 |
+
target_modules_dit: []
|
| 33 |
+
|
VoxCPM/conf/voxcpm/experiments/exp_06_both_scale05.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 实验 06: LM + DiT LoRA, scaling=0.5 (r=32, alpha=16)
|
| 2 |
+
# 预期: 可能不 work(LM 改变会影响 stop predictor)
|
| 3 |
+
pretrained_path: /user/zhouyixuan/ckpt/VoxCPM-0.5B-20250912-decay/
|
| 4 |
+
train_manifest: /user/liuxin/workspace/data/mianduan/1104-miantuan-data/metadata.jsonl
|
| 5 |
+
val_manifest: null
|
| 6 |
+
sample_rate: 16000
|
| 7 |
+
batch_size: 16
|
| 8 |
+
grad_accum_steps: 1
|
| 9 |
+
num_workers: 2
|
| 10 |
+
num_iters: 2000
|
| 11 |
+
log_interval: 10
|
| 12 |
+
valid_interval: 500
|
| 13 |
+
save_interval: 500
|
| 14 |
+
learning_rate: 0.0002
|
| 15 |
+
weight_decay: 0.01
|
| 16 |
+
warmup_steps: 200
|
| 17 |
+
max_steps: 2000
|
| 18 |
+
max_batch_tokens: 8192
|
| 19 |
+
save_path: /user/liuxin/checkpoints/voxcpm_exp/exp_06_both_scale05
|
| 20 |
+
tensorboard: /user/liuxin/checkpoints/logs/exp_06
|
| 21 |
+
lambdas:
|
| 22 |
+
loss/diff: 1.0
|
| 23 |
+
loss/stop: 1.0
|
| 24 |
+
lora:
|
| 25 |
+
enable_lm: true
|
| 26 |
+
enable_dit: true
|
| 27 |
+
enable_proj: false
|
| 28 |
+
r: 32
|
| 29 |
+
alpha: 16 # scaling = 16/32 = 0.5
|
| 30 |
+
dropout: 0.0
|
| 31 |
+
target_modules_lm: ["q_proj", "v_proj", "k_proj", "o_proj"] # 仅 attention
|
| 32 |
+
target_modules_dit: ["q_proj", "v_proj", "k_proj", "o_proj"]
|
| 33 |
+
|
VoxCPM/conf/voxcpm/experiments/exp_07_both_scale025.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 实验 07: LM + DiT LoRA, scaling=0.25 (r=32, alpha=8)
|
| 2 |
+
# 预期: 边界实验,极小 scaling 可能让 LM+DiT 组合 work
|
| 3 |
+
pretrained_path: /user/zhouyixuan/ckpt/VoxCPM-0.5B-20250912-decay/
|
| 4 |
+
train_manifest: /user/liuxin/workspace/data/mianduan/1104-miantuan-data/metadata.jsonl
|
| 5 |
+
val_manifest: null
|
| 6 |
+
sample_rate: 16000
|
| 7 |
+
batch_size: 16
|
| 8 |
+
grad_accum_steps: 1
|
| 9 |
+
num_workers: 2
|
| 10 |
+
num_iters: 2000
|
| 11 |
+
log_interval: 10
|
| 12 |
+
valid_interval: 500
|
| 13 |
+
save_interval: 500
|
| 14 |
+
learning_rate: 0.0002
|
| 15 |
+
weight_decay: 0.01
|
| 16 |
+
warmup_steps: 200
|
| 17 |
+
max_steps: 2000
|
| 18 |
+
max_batch_tokens: 8192
|
| 19 |
+
save_path: /user/liuxin/checkpoints/voxcpm_exp/exp_07_both_scale025
|
| 20 |
+
tensorboard: /user/liuxin/checkpoints/logs/exp_07
|
| 21 |
+
lambdas:
|
| 22 |
+
loss/diff: 1.0
|
| 23 |
+
loss/stop: 1.0
|
| 24 |
+
lora:
|
| 25 |
+
enable_lm: true
|
| 26 |
+
enable_dit: true
|
| 27 |
+
enable_proj: false
|
| 28 |
+
r: 32
|
| 29 |
+
alpha: 8 # scaling = 8/32 = 0.25
|
| 30 |
+
dropout: 0.0
|
| 31 |
+
target_modules_lm: ["q_proj", "v_proj", "k_proj", "o_proj"] # 仅 attention
|
| 32 |
+
target_modules_dit: ["q_proj", "v_proj", "k_proj", "o_proj"]
|
| 33 |
+
|
VoxCPM/conf/voxcpm/experiments/exp_08_dit_only_small_r.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 实验 08: 仅 DiT LoRA, 小 rank (r=8, alpha=8, scaling=1.0)
|
| 2 |
+
# 预期: work,测试小 rank 是否足够
|
| 3 |
+
pretrained_path: /user/zhouyixuan/ckpt/VoxCPM-0.5B-20250912-decay/
|
| 4 |
+
train_manifest: /user/liuxin/workspace/data/mianduan/1104-miantuan-data/metadata.jsonl
|
| 5 |
+
val_manifest: null
|
| 6 |
+
sample_rate: 16000
|
| 7 |
+
batch_size: 16
|
| 8 |
+
grad_accum_steps: 1
|
| 9 |
+
num_workers: 2
|
| 10 |
+
num_iters: 2000
|
| 11 |
+
log_interval: 10
|
| 12 |
+
valid_interval: 500
|
| 13 |
+
save_interval: 500
|
| 14 |
+
learning_rate: 0.0002
|
| 15 |
+
weight_decay: 0.01
|
| 16 |
+
warmup_steps: 200
|
| 17 |
+
max_steps: 2000
|
| 18 |
+
max_batch_tokens: 8192
|
| 19 |
+
save_path: /user/liuxin/checkpoints/voxcpm_exp/exp_08_dit_only_small_r
|
| 20 |
+
tensorboard: /user/liuxin/checkpoints/logs/exp_08
|
| 21 |
+
lambdas:
|
| 22 |
+
loss/diff: 1.0
|
| 23 |
+
loss/stop: 1.0
|
| 24 |
+
lora:
|
| 25 |
+
enable_lm: false
|
| 26 |
+
enable_dit: true
|
| 27 |
+
enable_proj: false
|
| 28 |
+
r: 8 # 小 rank
|
| 29 |
+
alpha: 8 # scaling = 8/8 = 1.0
|
| 30 |
+
dropout: 0.0
|
| 31 |
+
target_modules_lm: []
|
| 32 |
+
target_modules_dit: ["q_proj", "v_proj", "k_proj", "o_proj"]
|
| 33 |
+
|
VoxCPM/conf/voxcpm/experiments/exp_09_dit_only_large_r.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 实验 09: 仅 DiT LoRA, 大 rank (r=64, alpha=64, scaling=1.0)
|
| 2 |
+
# 预期: work,测试大 rank 是否有更好的效果
|
| 3 |
+
pretrained_path: /user/zhouyixuan/ckpt/VoxCPM-0.5B-20250912-decay/
|
| 4 |
+
train_manifest: /user/liuxin/workspace/data/mianduan/1104-miantuan-data/metadata.jsonl
|
| 5 |
+
val_manifest: null
|
| 6 |
+
sample_rate: 16000
|
| 7 |
+
batch_size: 16
|
| 8 |
+
grad_accum_steps: 1
|
| 9 |
+
num_workers: 2
|
| 10 |
+
num_iters: 2000
|
| 11 |
+
log_interval: 10
|
| 12 |
+
valid_interval: 500
|
| 13 |
+
save_interval: 500
|
| 14 |
+
learning_rate: 0.0002
|
| 15 |
+
weight_decay: 0.01
|
| 16 |
+
warmup_steps: 200
|
| 17 |
+
max_steps: 2000
|
| 18 |
+
max_batch_tokens: 8192
|
| 19 |
+
save_path: /user/liuxin/checkpoints/voxcpm_exp/exp_09_dit_only_large_r
|
| 20 |
+
tensorboard: /user/liuxin/checkpoints/logs/exp_09
|
| 21 |
+
lambdas:
|
| 22 |
+
loss/diff: 1.0
|
| 23 |
+
loss/stop: 1.0
|
| 24 |
+
lora:
|
| 25 |
+
enable_lm: false
|
| 26 |
+
enable_dit: true
|
| 27 |
+
enable_proj: false
|
| 28 |
+
r: 64 # 大 rank
|
| 29 |
+
alpha: 64 # scaling = 64/64 = 1.0
|
| 30 |
+
dropout: 0.0
|
| 31 |
+
target_modules_lm: []
|
| 32 |
+
target_modules_dit: ["q_proj", "v_proj", "k_proj", "o_proj"]
|
| 33 |
+
|
VoxCPM/conf/voxcpm/experiments/exp_10_dit_only_more_modules.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 实验 10: 仅 DiT LoRA, 更多目标模块 (包含 MLP)
|
| 2 |
+
# 预期: work,测试更多模块是否有更好的效果
|
| 3 |
+
pretrained_path: /user/zhouyixuan/ckpt/VoxCPM-0.5B-20250912-decay/
|
| 4 |
+
train_manifest: /user/liuxin/workspace/data/mianduan/1104-miantuan-data/metadata.jsonl
|
| 5 |
+
val_manifest: null
|
| 6 |
+
sample_rate: 16000
|
| 7 |
+
batch_size: 16
|
| 8 |
+
grad_accum_steps: 1
|
| 9 |
+
num_workers: 2
|
| 10 |
+
num_iters: 2000
|
| 11 |
+
log_interval: 10
|
| 12 |
+
valid_interval: 500
|
| 13 |
+
save_interval: 500
|
| 14 |
+
learning_rate: 0.0002
|
| 15 |
+
weight_decay: 0.01
|
| 16 |
+
warmup_steps: 200
|
| 17 |
+
max_steps: 2000
|
| 18 |
+
max_batch_tokens: 8192
|
| 19 |
+
save_path: /user/liuxin/checkpoints/voxcpm_exp/exp_10_dit_only_more_modules
|
| 20 |
+
tensorboard: /user/liuxin/checkpoints/logs/exp_10
|
| 21 |
+
lambdas:
|
| 22 |
+
loss/diff: 1.0
|
| 23 |
+
loss/stop: 1.0
|
| 24 |
+
lora:
|
| 25 |
+
enable_lm: false
|
| 26 |
+
enable_dit: true
|
| 27 |
+
enable_proj: false
|
| 28 |
+
r: 32
|
| 29 |
+
alpha: 16 # scaling = 0.5
|
| 30 |
+
dropout: 0.0
|
| 31 |
+
target_modules_lm: []
|
| 32 |
+
target_modules_dit: ["q_proj", "v_proj", "k_proj", "o_proj", "gate_proj", "down_proj", "up_proj"] # 包含 MLP
|
| 33 |
+
|
VoxCPM/conf/voxcpm/voxcpm_finetune_example.yaml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pretrained_path: ckpts
|
| 2 |
+
train_manifest: datasets/metadatas/single_speaker_train_datas.jsonl
|
| 3 |
+
val_manifest: null
|
| 4 |
+
sample_rate: 16000
|
| 5 |
+
batch_size: 8
|
| 6 |
+
grad_accum_steps: 1 # 梯度累积步数,>1 时可在不增大显存的情况下提升等效 batch size
|
| 7 |
+
num_workers: 2
|
| 8 |
+
num_iters: 1000
|
| 9 |
+
log_interval: 1
|
| 10 |
+
valid_interval: 100
|
| 11 |
+
save_interval: 100
|
| 12 |
+
learning_rate: 0.00001
|
| 13 |
+
weight_decay: 0.01
|
| 14 |
+
warmup_steps: 10
|
| 15 |
+
max_steps: 1000
|
| 16 |
+
max_batch_tokens: 0 # 0 表示不启用长度过滤;>0 时按 batch 总 token 上限过滤超长样本
|
| 17 |
+
save_path: checkpoints/voxcpm_finetune
|
| 18 |
+
tensorboard: logs/voxcpm_finetune
|
| 19 |
+
lambdas:
|
| 20 |
+
loss/diff: 1.0
|
| 21 |
+
loss/stop: 1.0
|
| 22 |
+
|
| 23 |
+
|
VoxCPM/conf/voxcpm/voxcpm_finetune_lora.yaml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pretrained_path: ckpts
|
| 2 |
+
train_manifest: datasets/metadatas/single_speaker_train_datas.jsonl
|
| 3 |
+
val_manifest: null
|
| 4 |
+
sample_rate: 16000
|
| 5 |
+
batch_size: 8
|
| 6 |
+
grad_accum_steps: 1 # 梯度累积步数,>1 时可在不增大显存的情况下提升等效 batch size
|
| 7 |
+
num_workers: 2
|
| 8 |
+
num_iters: 2000
|
| 9 |
+
log_interval: 1
|
| 10 |
+
valid_interval: 100
|
| 11 |
+
save_interval: 100
|
| 12 |
+
learning_rate: 0.0001 # Increased for LoRA (original 1e-5 is too small for LoRA)
|
| 13 |
+
weight_decay: 0.01
|
| 14 |
+
warmup_steps: 10
|
| 15 |
+
max_steps: 2000
|
| 16 |
+
max_batch_tokens: 8192 # 例:单个 batch 最多 16k token,按 batch_size=4 则单样本约 4096 token 上限
|
| 17 |
+
save_path: checkpoints/voxcpm_finetune
|
| 18 |
+
tensorboard: logs/voxcpm_finetune
|
| 19 |
+
lambdas:
|
| 20 |
+
loss/diff: 1.0
|
| 21 |
+
loss/stop: 1.0
|
| 22 |
+
lora:
|
| 23 |
+
enable_lm: true # 是否微调LM模型
|
| 24 |
+
enable_dit: true # 是否微调DiT模型
|
| 25 |
+
enable_proj: false # 是否微调投影层
|
| 26 |
+
r: 32 # Increased rank
|
| 27 |
+
alpha: 16 # Increased alpha (scaling = alpha/r = 2.0)
|
| 28 |
+
dropout: 0.0 # Added dropout
|
| 29 |
+
target_modules_lm: ["q_proj", "v_proj", "k_proj", "o_proj"] # LM模型要微调的层
|
| 30 |
+
target_modules_dit: ["q_proj", "v_proj", "k_proj", "o_proj"] # DiT模型要微调的层
|
| 31 |
+
target_proj_modules: ["enc_to_lm_proj", "lm_to_dit_proj", "res_to_dit_proj"] # 投影层要微调的层
|
VoxCPM/datasets.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f4f3ef25fb26393336239176dcbc46266f67804990a953ba4ebb300b09eb878f
|
| 3 |
+
size 28233400938
|
VoxCPM/docs/finetune.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# VoxCPM 微调指南
|
| 2 |
+
|
| 3 |
+
本文档介绍如何对 VoxCPM 模型进行微调,支持全量微调和 LoRA 微调两种方式。
|
| 4 |
+
|
| 5 |
+
## 目录
|
| 6 |
+
|
| 7 |
+
- [数据准备](#数据准备)
|
| 8 |
+
- [全量微调](#全量微调)
|
| 9 |
+
- [LoRA 微调](#lora-微调)
|
| 10 |
+
- [推理测试](#推理测试)
|
| 11 |
+
- [LoRA 热切换](#lora-热切换)
|
| 12 |
+
- [常见问题](#常见问题)
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## 数据准备
|
| 17 |
+
|
| 18 |
+
训练数据需要准备为 JSONL 格式的 manifest 文件,每行包含一条训练样本:
|
| 19 |
+
|
| 20 |
+
```json
|
| 21 |
+
{"audio_path": "/path/to/audio1.wav", "text": "对应的文本内容"}
|
| 22 |
+
{"audio_path": "/path/to/audio2.wav", "text": "另一条文本"}
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
**要求**:
|
| 26 |
+
- 音频格式:WAV,采样率 16kHz
|
| 27 |
+
- 文本:与音频对应的转录文本
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## 全量微调
|
| 32 |
+
|
| 33 |
+
全量微调会更新模型的所有参数,适合数据量较大、需要显著改变模型行为的场景。
|
| 34 |
+
|
| 35 |
+
### 配置文件
|
| 36 |
+
|
| 37 |
+
创建配置文件 `conf/voxcpm/voxcpm_finetune_all.yaml`:
|
| 38 |
+
|
| 39 |
+
```yaml
|
| 40 |
+
pretrained_path: /path/to/VoxCPM-0.5B/ # 预训练模型路径
|
| 41 |
+
train_manifest: /path/to/train_manifest.jsonl # 训练数据
|
| 42 |
+
val_manifest: null # 验证数据(可选)
|
| 43 |
+
|
| 44 |
+
sample_rate: 16000
|
| 45 |
+
batch_size: 16
|
| 46 |
+
grad_accum_steps: 1 # 梯度累积步数,显存不足时可增大
|
| 47 |
+
num_workers: 2
|
| 48 |
+
num_iters: 2000
|
| 49 |
+
log_interval: 10
|
| 50 |
+
valid_interval: 1000
|
| 51 |
+
save_interval: 1000
|
| 52 |
+
|
| 53 |
+
learning_rate: 0.00001 # 全量微调建议较小的学习率
|
| 54 |
+
weight_decay: 0.01
|
| 55 |
+
warmup_steps: 100
|
| 56 |
+
max_steps: 2000
|
| 57 |
+
max_batch_tokens: 8192
|
| 58 |
+
|
| 59 |
+
save_path: /path/to/checkpoints/finetune_all
|
| 60 |
+
tensorboard: /path/to/logs/finetune_all
|
| 61 |
+
|
| 62 |
+
lambdas:
|
| 63 |
+
loss/diff: 1.0
|
| 64 |
+
loss/stop: 1.0
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
### 启动训练
|
| 68 |
+
|
| 69 |
+
```bash
|
| 70 |
+
python scripts/train_voxcpm_finetune.py --config_path conf/voxcpm/voxcpm_finetune_all.yaml
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## LoRA 微调
|
| 76 |
+
|
| 77 |
+
LoRA(Low-Rank Adaptation)是一种参数高效的微调方法,只训练少量额外参数,显著降低显存需求。
|
| 78 |
+
|
| 79 |
+
### 配置文件
|
| 80 |
+
|
| 81 |
+
创建配置文件 `conf/voxcpm/voxcpm_finetune_lora.yaml`:
|
| 82 |
+
|
| 83 |
+
```yaml
|
| 84 |
+
pretrained_path: /path/to/VoxCPM-0.5B/
|
| 85 |
+
train_manifest: /path/to/train_manifest.jsonl
|
| 86 |
+
val_manifest: null
|
| 87 |
+
|
| 88 |
+
sample_rate: 16000
|
| 89 |
+
batch_size: 16
|
| 90 |
+
grad_accum_steps: 1
|
| 91 |
+
num_workers: 2
|
| 92 |
+
num_iters: 2000
|
| 93 |
+
log_interval: 10
|
| 94 |
+
valid_interval: 1000
|
| 95 |
+
save_interval: 1000
|
| 96 |
+
|
| 97 |
+
learning_rate: 0.0001 # LoRA 可以使用较大的学习率
|
| 98 |
+
weight_decay: 0.01
|
| 99 |
+
warmup_steps: 200
|
| 100 |
+
max_steps: 2000
|
| 101 |
+
max_batch_tokens: 8192
|
| 102 |
+
|
| 103 |
+
save_path: /path/to/checkpoints/finetune_lora
|
| 104 |
+
tensorboard: /path/to/logs/finetune_lora
|
| 105 |
+
|
| 106 |
+
lambdas:
|
| 107 |
+
loss/diff: 1.0
|
| 108 |
+
loss/stop: 1.0
|
| 109 |
+
|
| 110 |
+
# LoRA 配置
|
| 111 |
+
lora:
|
| 112 |
+
enable_lm: true # 对 Language Model 加 LoRA
|
| 113 |
+
enable_dit: true # 对 Diffusion Transformer 加 LoRA
|
| 114 |
+
enable_proj: false # 对投影层加 LoRA(可选)
|
| 115 |
+
|
| 116 |
+
r: 32 # LoRA 秩(rank),越大容量越大
|
| 117 |
+
alpha: 16 # LoRA alpha,scaling = alpha / r
|
| 118 |
+
dropout: 0.0 # LoRA dropout
|
| 119 |
+
|
| 120 |
+
# 目标模块
|
| 121 |
+
target_modules_lm: ["q_proj", "v_proj", "k_proj", "o_proj"]
|
| 122 |
+
target_modules_dit: ["q_proj", "v_proj", "k_proj", "o_proj"]
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
### LoRA 参数说明
|
| 126 |
+
|
| 127 |
+
| 参数 | 说明 | 建议值 |
|
| 128 |
+
|------|------|--------|
|
| 129 |
+
| `enable_lm` | 对 LM(语言模型)加 LoRA | `true` |
|
| 130 |
+
| `enable_dit` | 对 DiT(扩散模型)加 LoRA | `true`(音色克隆必须) |
|
| 131 |
+
| `r` | LoRA 秩,越大容量越大 | 16-64 |
|
| 132 |
+
| `alpha` | 缩放因子,`scaling = alpha / r` | 通常设为 `r/2` 或 `r` |
|
| 133 |
+
| `target_modules_*` | 要添加 LoRA 的层名 | attention 层 |
|
| 134 |
+
|
| 135 |
+
### 启动训练
|
| 136 |
+
|
| 137 |
+
```bash
|
| 138 |
+
python scripts/train_voxcpm_finetune.py --config_path conf/voxcpm/voxcpm_finetune_lora.yaml
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
### Checkpoint 结构
|
| 142 |
+
|
| 143 |
+
LoRA 训练保存的 checkpoint 只包含 LoRA 参数:
|
| 144 |
+
|
| 145 |
+
```
|
| 146 |
+
checkpoints/finetune_lora/
|
| 147 |
+
└── step_0002000/
|
| 148 |
+
└── generator.pth # 仅包含 lora_A, lora_B 参数
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
---
|
| 152 |
+
|
| 153 |
+
## 推理测试
|
| 154 |
+
|
| 155 |
+
### 全量微调推理
|
| 156 |
+
|
| 157 |
+
```bash
|
| 158 |
+
python scripts/test_voxcpm_ft_infer.py \
|
| 159 |
+
--pretrained_path /path/to/VoxCPM-0.5B/ \
|
| 160 |
+
--ft_ckpt /path/to/checkpoints/finetune_all/step_0002000 \
|
| 161 |
+
--text "你好,这是微调后的效果。" \
|
| 162 |
+
--output output.wav
|
| 163 |
+
```
|
| 164 |
+
|
| 165 |
+
### LoRA 推理
|
| 166 |
+
|
| 167 |
+
```bash
|
| 168 |
+
python scripts/test_voxcpm_lora_infer.py \
|
| 169 |
+
--config_path conf/voxcpm/voxcpm_finetune_lora.yaml \
|
| 170 |
+
--lora_ckpt /path/to/checkpoints/finetune_lora/step_0002000 \
|
| 171 |
+
--text "你好,这是 LoRA 微调后的效果。" \
|
| 172 |
+
--output lora_output.wav
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
### 带参考音频(音色克隆)
|
| 176 |
+
|
| 177 |
+
```bash
|
| 178 |
+
python scripts/test_voxcpm_lora_infer.py \
|
| 179 |
+
--config_path conf/voxcpm/voxcpm_finetune_lora.yaml \
|
| 180 |
+
--lora_ckpt /path/to/checkpoints/finetune_lora/step_0002000 \
|
| 181 |
+
--text "这是带参考音色的合成效果。" \
|
| 182 |
+
--prompt_audio /path/to/reference.wav \
|
| 183 |
+
--prompt_text "参考音频对应的文本" \
|
| 184 |
+
--output cloned_output.wav
|
| 185 |
+
```
|
| 186 |
+
|
| 187 |
+
---
|
| 188 |
+
|
| 189 |
+
## LoRA 热切换
|
| 190 |
+
|
| 191 |
+
LoRA 支持在推理时动态加载、卸载和切换,无需重新加载整个模型。
|
| 192 |
+
|
| 193 |
+
### API 说明
|
| 194 |
+
|
| 195 |
+
```python
|
| 196 |
+
from voxcpm.model import VoxCPMModel
|
| 197 |
+
from voxcpm.model.voxcpm import LoRAConfig
|
| 198 |
+
|
| 199 |
+
# 1. 加载模型(包含 LoRA 结构)
|
| 200 |
+
lora_cfg = LoRAConfig(enable_lm=True, enable_dit=True, r=32, alpha=16, ...)
|
| 201 |
+
model = VoxCPMModel.from_local(
|
| 202 |
+
pretrained_path,
|
| 203 |
+
optimize=True, # 启用 torch.compile 加速
|
| 204 |
+
lora_config=lora_cfg
|
| 205 |
+
)
|
| 206 |
+
|
| 207 |
+
# 2. 加载 LoRA 权重(支持 compile 后调用)
|
| 208 |
+
model.load_lora_weights("/path/to/lora_checkpoint")
|
| 209 |
+
|
| 210 |
+
# 3. 禁用 LoRA(使用基础模型)
|
| 211 |
+
model.set_lora_enabled(False)
|
| 212 |
+
|
| 213 |
+
# 4. 重新启用 LoRA
|
| 214 |
+
model.set_lora_enabled(True)
|
| 215 |
+
|
| 216 |
+
# 5. 卸载 LoRA(重置权重为 0)
|
| 217 |
+
model.reset_lora_weights()
|
| 218 |
+
|
| 219 |
+
# 6. 热切换到另一个 LoRA
|
| 220 |
+
model.load_lora_weights("/path/to/another_lora_checkpoint")
|
| 221 |
+
```
|
| 222 |
+
|
| 223 |
+
### 方法说明
|
| 224 |
+
|
| 225 |
+
| 方法 | 功能 | 兼容 torch.compile |
|
| 226 |
+
|------|------|-------------------|
|
| 227 |
+
| `load_lora_weights(path)` | 从文件加载 LoRA 权重 | ✅ |
|
| 228 |
+
| `set_lora_enabled(bool)` | 启用/禁用 LoRA | ✅ |
|
| 229 |
+
| `reset_lora_weights()` | 重置 LoRA 权重为初始值 | ✅ |
|
| 230 |
+
| `get_lora_state_dict()` | 获取当前 LoRA 权重 | ✅ |
|
| 231 |
+
|
| 232 |
+
---
|
| 233 |
+
|
| 234 |
+
## 常见问题
|
| 235 |
+
|
| 236 |
+
### 1. 显存不足
|
| 237 |
+
|
| 238 |
+
- 增大 `grad_accum_steps`(梯度累积)
|
| 239 |
+
- 减小 `batch_size`
|
| 240 |
+
- 使用 LoRA 微调代替全量微调
|
| 241 |
+
|
| 242 |
+
### 2. LoRA 效果不好
|
| 243 |
+
|
| 244 |
+
- 增大 `r`(LoRA 秩)
|
| 245 |
+
- 调整 `alpha`(建议 `alpha = r/2` 或 `alpha = r`)
|
| 246 |
+
- 确保 `enable_dit: true`(音色克隆必须)
|
| 247 |
+
- 增加训练步数
|
| 248 |
+
|
| 249 |
+
### 3. 训练不收敛
|
| 250 |
+
|
| 251 |
+
- 降低 `learning_rate`
|
| 252 |
+
- 增加 `warmup_steps`
|
| 253 |
+
- 检查数据质量
|
| 254 |
+
|
| 255 |
+
### 4. 推理时 LoRA 不生效
|
| 256 |
+
|
| 257 |
+
- 确保推理配置与训练配置的 LoRA 参数一致
|
| 258 |
+
- 检查 `load_lora_weights` 返回的 `skipped_keys` 是否为空
|
| 259 |
+
|
| 260 |
+
|
VoxCPM/examples/example.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:009638e7474ac4eb2ca5b23d28d9114c33377eb5c91e8d6f7000a0c36d6eaa8e
|
| 3 |
+
size 1439096
|
VoxCPM/inference.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import soundfile as sf
|
| 2 |
+
import numpy as np
|
| 3 |
+
from voxcpm import VoxCPM
|
| 4 |
+
import argparse
|
| 5 |
+
import os
|
| 6 |
+
def main():
|
| 7 |
+
parser = argparse.ArgumentParser()
|
| 8 |
+
parser.add_argument("--model_path", type=str, required=True)
|
| 9 |
+
parser.add_argument("--text", type=str)
|
| 10 |
+
parser.add_argument("--text_file", type=str)
|
| 11 |
+
parser.add_argument("--output_dir", type=str, default="outputs")
|
| 12 |
+
parser.add_argument("--cfg_value", type=float, default=2.0)
|
| 13 |
+
parser.add_argument("--inference_timesteps", type=int, default=10)
|
| 14 |
+
parser.add_argument("--prompt_wav_path", type=str)
|
| 15 |
+
parser.add_argument("--prompt_text", type=str)
|
| 16 |
+
args = parser.parse_args()
|
| 17 |
+
assert args.text or args.text_file, "Please provide either text or text_file"
|
| 18 |
+
# validate prompt_wav_path and prompt_text 必须同时提供
|
| 19 |
+
if args.prompt_wav_path or args.prompt_text:
|
| 20 |
+
assert args.prompt_wav_path and args.prompt_text, "Please provide both prompt_wav_path and prompt_text"
|
| 21 |
+
model = VoxCPM.from_pretrained(args.model_path, load_denoiser=False)
|
| 22 |
+
if args.text:
|
| 23 |
+
wav = model.generate(
|
| 24 |
+
text=args.text,
|
| 25 |
+
prompt_wav_path=args.prompt_wav_path, # optional: path to a prompt speech for voice cloning
|
| 26 |
+
prompt_text=args.prompt_text, # optional: reference text
|
| 27 |
+
cfg_value=args.cfg_value, # LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse
|
| 28 |
+
inference_timesteps=args.inference_timesteps, # LocDiT inference timesteps, higher for better result, lower for fast speed
|
| 29 |
+
normalize=True, # enable external TN tool
|
| 30 |
+
denoise=False, # enable external Denoise tool
|
| 31 |
+
retry_badcase=True, # enable retrying mode for some bad cases (unstoppable)
|
| 32 |
+
retry_badcase_max_times=3, # maximum retrying times
|
| 33 |
+
retry_badcase_ratio_threshold=6.0, # maximum length restriction for bad case detection (simple but effective), it could be adjusted for slow pace speech
|
| 34 |
+
)
|
| 35 |
+
if not os.path.exists(args.output_dir):
|
| 36 |
+
os.makedirs(args.output_dir)
|
| 37 |
+
sf.write(f"{args.output_dir}/output.wav", wav, 16000)
|
| 38 |
+
print(f"saved: {args.output_dir}/output.wav")
|
| 39 |
+
elif args.text_file:
|
| 40 |
+
texts = []
|
| 41 |
+
with open(args.text_file, "r") as f:
|
| 42 |
+
lines = f.readlines()
|
| 43 |
+
for line in lines:
|
| 44 |
+
line = line.strip().split("||")
|
| 45 |
+
wav_id = line[0]
|
| 46 |
+
text = " ".join(line[1:])
|
| 47 |
+
texts.append((wav_id, text))
|
| 48 |
+
for wav_id, text in texts:
|
| 49 |
+
wav = model.generate(
|
| 50 |
+
text=text,
|
| 51 |
+
prompt_wav_path=args.prompt_wav_path, # optional: path to a prompt speech for voice cloning
|
| 52 |
+
prompt_text=args.prompt_text, # optional: reference text
|
| 53 |
+
cfg_value=args.cfg_value, # LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse
|
| 54 |
+
inference_timesteps=args.inference_timesteps, # LocDiT inference timesteps, higher for better result, lower for fast speed
|
| 55 |
+
normalize=True, # enable external TN tool
|
| 56 |
+
denoise=False, # enable external Denoise tool
|
| 57 |
+
retry_badcase=True, # enable retrying mode for some bad cases (unstoppable)
|
| 58 |
+
retry_badcase_max_times=3, # maximum retrying times
|
| 59 |
+
retry_badcase_ratio_threshold=6.0, # maximum length restriction for bad case detection (simple but effective), it could be adjusted for slow pace speech
|
| 60 |
+
)
|
| 61 |
+
if not os.path.exists(args.output_dir):
|
| 62 |
+
os.makedirs(args.output_dir)
|
| 63 |
+
sf.write(f"{args.output_dir}/{wav_id}.wav", wav, 16000)
|
| 64 |
+
print(f"saved: {args.output_dir}/{wav_id}.wav")
|
| 65 |
+
|
| 66 |
+
if __name__ == "__main__":
|
| 67 |
+
main()
|
VoxCPM/inference_lora.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import soundfile as sf
|
| 2 |
+
import numpy as np
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
from voxcpm.model import VoxCPMModel
|
| 5 |
+
from voxcpm.model.voxcpm import LoRAConfig
|
| 6 |
+
from voxcpm.training.config import load_yaml_config
|
| 7 |
+
import argparse
|
| 8 |
+
import torch
|
| 9 |
+
import os
|
| 10 |
+
|
| 11 |
+
def main():
|
| 12 |
+
parser = argparse.ArgumentParser()
|
| 13 |
+
parser.add_argument("--lora_ckpt", type=str, required=True)
|
| 14 |
+
parser.add_argument("--lora_config_path", type=str, required=True)
|
| 15 |
+
parser.add_argument("--text", type=str)
|
| 16 |
+
parser.add_argument("--text_file", type=str)
|
| 17 |
+
parser.add_argument("--output_dir", type=str, default="outputs")
|
| 18 |
+
parser.add_argument("--cfg_value", type=float, default=2.0)
|
| 19 |
+
parser.add_argument("--inference_timesteps", type=int, default=10)
|
| 20 |
+
args = parser.parse_args()
|
| 21 |
+
assert args.text or args.text_file, "Please provide either text or text_file"
|
| 22 |
+
|
| 23 |
+
# 1. 读取 YAML 配置
|
| 24 |
+
cfg = load_yaml_config(args.lora_config_path)
|
| 25 |
+
pretrained_path = cfg["pretrained_path"]
|
| 26 |
+
lora_cfg_dict = cfg.get("lora", {}) or {}
|
| 27 |
+
lora_cfg = LoRAConfig(**lora_cfg_dict) if lora_cfg_dict else None
|
| 28 |
+
|
| 29 |
+
# 2. 加载基础模型(包含 LoRA 结构,并执行 torch.compile)
|
| 30 |
+
print(f"[1/3] 加载基础模型:{pretrained_path}")
|
| 31 |
+
model = VoxCPMModel.from_local(
|
| 32 |
+
pretrained_path,
|
| 33 |
+
optimize=True, # 先 compile,load_lora_weights 使用 named_parameters 兼容
|
| 34 |
+
training=False,
|
| 35 |
+
lora_config=lora_cfg,
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
# 3. 加载 LoRA 权重(在 compile 后也能正常工作)
|
| 39 |
+
ckpt_dir = Path(args.lora_ckpt)
|
| 40 |
+
if not ckpt_dir.exists():
|
| 41 |
+
raise FileNotFoundError(f"找不到 LoRA checkpoint: {ckpt_dir}")
|
| 42 |
+
|
| 43 |
+
print(f"[2/3] 加载 LoRA 权重:{ckpt_dir}")
|
| 44 |
+
loaded, skipped = model.load_lora_weights(str(ckpt_dir))
|
| 45 |
+
print(f" 已加载 {len(loaded)} 个参数")
|
| 46 |
+
if skipped:
|
| 47 |
+
print(f"[WARNING] 跳过 {len(skipped)} 个参数")
|
| 48 |
+
print(f" 跳过的 key (前5个): {skipped[:5]}")
|
| 49 |
+
print(f"\n[3/3] 开始推理...")
|
| 50 |
+
if args.text:
|
| 51 |
+
with torch.inference_mode():
|
| 52 |
+
wav = model.generate(
|
| 53 |
+
target_text=args.text,
|
| 54 |
+
cfg_value=args.cfg_value, # LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse
|
| 55 |
+
inference_timesteps=args.inference_timesteps, # LocDiT inference timesteps, higher for better result, lower for fast speed
|
| 56 |
+
retry_badcase=True, # enable retrying mode for some bad cases (unstoppable)
|
| 57 |
+
retry_badcase_max_times=3, # maximum retrying times
|
| 58 |
+
retry_badcase_ratio_threshold=6.0, # maximum length restriction for bad case detection (simple but effective), it could be adjusted for slow pace speech
|
| 59 |
+
)
|
| 60 |
+
audio_np = wav.squeeze(0).cpu().numpy() if wav.dim() > 1 else wav.cpu().numpy()
|
| 61 |
+
if not os.path.exists(args.output_dir):
|
| 62 |
+
os.makedirs(args.output_dir)
|
| 63 |
+
sf.write(f"{args.output_dir}/output_lora.wav", audio_np, 16000)
|
| 64 |
+
print(f"saved: {args.output_dir}/output_lora.wav")
|
| 65 |
+
elif args.text_file:
|
| 66 |
+
texts = []
|
| 67 |
+
with open(args.text_file, "r") as f:
|
| 68 |
+
lines = f.readlines()
|
| 69 |
+
for line in lines:
|
| 70 |
+
line = line.strip().split("||")
|
| 71 |
+
wav_id = line[0]
|
| 72 |
+
text = " ".join(line[1:])
|
| 73 |
+
texts.append((wav_id, text))
|
| 74 |
+
for wav_id, text in texts:
|
| 75 |
+
with torch.inference_mode():
|
| 76 |
+
wav = model.generate(
|
| 77 |
+
target_text=text,
|
| 78 |
+
cfg_value=args.cfg_value, # LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse
|
| 79 |
+
inference_timesteps=args.inference_timesteps, # LocDiT inference timesteps, higher for better result, lower for fast speed
|
| 80 |
+
retry_badcase=True, # enable retrying mode for some bad cases (unstoppable)
|
| 81 |
+
retry_badcase_max_times=3, # maximum retrying times
|
| 82 |
+
retry_badcase_ratio_threshold=6.0, # maximum length restriction for bad case detection (simple but effective), it could be adjusted for slow pace speech
|
| 83 |
+
)
|
| 84 |
+
audio_np = wav.squeeze(0).cpu().numpy() if wav.dim() > 1 else wav.cpu().numpy()
|
| 85 |
+
if not os.path.exists(args.output_dir):
|
| 86 |
+
os.makedirs(args.output_dir)
|
| 87 |
+
sf.write(f"{args.output_dir}/{wav_id}.wav", audio_np, 16000)
|
| 88 |
+
print(f"saved: {args.output_dir}/{wav_id}.wav")
|
| 89 |
+
|
| 90 |
+
if __name__ == "__main__":
|
| 91 |
+
main()
|
VoxCPM/prompt_sample.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3efe60d997679f3d6dcd94531cd93e4c9d4536c618133a4af5fa87f7981e1d5f
|
| 3 |
+
size 401196
|
VoxCPM/pyproject.toml
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[build-system]
|
| 2 |
+
requires = ["setuptools>=64", "wheel", "setuptools_scm>=8"]
|
| 3 |
+
build-backend = "setuptools.build_meta"
|
| 4 |
+
|
| 5 |
+
[project]
|
| 6 |
+
name = "voxcpm"
|
| 7 |
+
dynamic = ["version"]
|
| 8 |
+
description = "VoxCPM: Tokenizer-Free TTS for Context-Aware Speech Generation and True-to-Life Voice Cloning"
|
| 9 |
+
readme = "README.md"
|
| 10 |
+
license = "Apache-2.0"
|
| 11 |
+
authors = [
|
| 12 |
+
{name = "OpenBMB", email = "openbmb@gmail.com"}
|
| 13 |
+
]
|
| 14 |
+
maintainers = [
|
| 15 |
+
{name = "OpenBMB", email = "openbmb@gmail.com"}
|
| 16 |
+
]
|
| 17 |
+
keywords = ["voxcpm", "text-to-speech", "tts", "speech-synthesis", "voice-cloning", "ai", "deep-learning", "pytorch"]
|
| 18 |
+
classifiers = [
|
| 19 |
+
"Development Status :: 3 - Alpha",
|
| 20 |
+
"Intended Audience :: Developers",
|
| 21 |
+
"Operating System :: OS Independent",
|
| 22 |
+
"Programming Language :: Python :: 3",
|
| 23 |
+
"Programming Language :: Python :: 3.10",
|
| 24 |
+
"Programming Language :: Python :: 3.11",
|
| 25 |
+
]
|
| 26 |
+
requires-python = ">=3.10"
|
| 27 |
+
dependencies = [
|
| 28 |
+
"torch>=2.5.0",
|
| 29 |
+
"torchaudio>=2.5.0",
|
| 30 |
+
"transformers>=4.36.2",
|
| 31 |
+
"einops",
|
| 32 |
+
"gradio",
|
| 33 |
+
"inflect",
|
| 34 |
+
"addict",
|
| 35 |
+
"wetext",
|
| 36 |
+
"modelscope>=1.22.0",
|
| 37 |
+
"datasets>=3,<4",
|
| 38 |
+
"huggingface-hub",
|
| 39 |
+
"pydantic",
|
| 40 |
+
"tqdm",
|
| 41 |
+
"simplejson",
|
| 42 |
+
"sortedcontainers",
|
| 43 |
+
"soundfile",
|
| 44 |
+
"funasr",
|
| 45 |
+
"spaces",
|
| 46 |
+
"argbind",
|
| 47 |
+
"tensorboardX",
|
| 48 |
+
]
|
| 49 |
+
|
| 50 |
+
[project.optional-dependencies]
|
| 51 |
+
dev = [
|
| 52 |
+
"pytest>=6.0",
|
| 53 |
+
"pytest-cov>=2.0",
|
| 54 |
+
"black>=21.0",
|
| 55 |
+
"flake8>=3.8",
|
| 56 |
+
"mypy>=0.800",
|
| 57 |
+
"pre-commit>=2.0",
|
| 58 |
+
]
|
| 59 |
+
|
| 60 |
+
[project.scripts]
|
| 61 |
+
voxcpm = "voxcpm.cli:main"
|
| 62 |
+
|
| 63 |
+
[project.urls]
|
| 64 |
+
Homepage = "https://github.com/OpenBMB/VoxCPM"
|
| 65 |
+
Repository = "https://github.com/OpenBMB/VoxCPM.git"
|
| 66 |
+
Documentation = "https://github.com/OpenBMB/VoxCPM#readme"
|
| 67 |
+
"Bug Tracker" = "https://github.com/OpenBMB/VoxCPM/issues"
|
| 68 |
+
|
| 69 |
+
[tool.setuptools.packages.find]
|
| 70 |
+
where = ["src"]
|
| 71 |
+
include = ["voxcpm*"]
|
| 72 |
+
|
| 73 |
+
[tool.setuptools.package-dir]
|
| 74 |
+
"" = "src"
|
| 75 |
+
|
| 76 |
+
[tool.setuptools_scm]
|
| 77 |
+
version_scheme = "post-release"
|
| 78 |
+
|
| 79 |
+
[tool.black]
|
| 80 |
+
line-length = 120
|
| 81 |
+
target-version = ['py310']
|
| 82 |
+
include = '\.pyi?$'
|
| 83 |
+
extend-exclude = '''
|
| 84 |
+
/(
|
| 85 |
+
# directories
|
| 86 |
+
\.eggs
|
| 87 |
+
| \.git
|
| 88 |
+
| \.hg
|
| 89 |
+
| \.mypy_cache
|
| 90 |
+
| \.tox
|
| 91 |
+
| \.venv
|
| 92 |
+
| build
|
| 93 |
+
| dist
|
| 94 |
+
)/
|
| 95 |
+
'''
|
VoxCPM/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
argbind
|
| 2 |
+
tensorboardX
|
VoxCPM/scripts/test_voxcpm_ft_infer.py
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
简单的全量微调权重推理测试脚本(无 LoRA):
|
| 4 |
+
|
| 5 |
+
1. 使用训练时相同的 YAML(拿到 pretrained_path)
|
| 6 |
+
2. 从 pretrained_path 加载基础 VoxCPM 模型(config.json / pytorch_model.bin / audiovae.pth)
|
| 7 |
+
3. 再从全量微调 checkpoint 目录加载微调后的 generator.pth(保存的是完整 state_dict)
|
| 8 |
+
4. 调用模型的 generate 接口合成语音并保存为 wav
|
| 9 |
+
|
| 10 |
+
用法示例(与你的 finetune 配置保持一致):
|
| 11 |
+
|
| 12 |
+
python scripts/test_voxcpm_ft_infer.py \
|
| 13 |
+
--config_path conf/voxcpm/voxcpm_finetune_test.yaml \
|
| 14 |
+
--ckpt_dir /user/liuxin/checkpoints/voxcpm_finetune/step_0001000 \
|
| 15 |
+
--text "你好,我是全量微调后的 VoxCPM。" \
|
| 16 |
+
--output ft_test.wav
|
| 17 |
+
|
| 18 |
+
如果需要参考音色克隆:
|
| 19 |
+
|
| 20 |
+
python scripts/test_voxcpm_ft_infer.py \
|
| 21 |
+
--config_path conf/voxcpm/voxcpm_finetune_test.yaml \
|
| 22 |
+
--ckpt_dir /user/liuxin/checkpoints/voxcpm_finetune/step_0001000 \
|
| 23 |
+
--text "你好,这是带参考音色的合成效果。" \
|
| 24 |
+
--prompt_audio path/to/ref.wav \
|
| 25 |
+
--prompt_text "参考音频对应的文本" \
|
| 26 |
+
--output ft_clone.wav
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
import argparse
|
| 30 |
+
from pathlib import Path
|
| 31 |
+
|
| 32 |
+
import soundfile as sf
|
| 33 |
+
import torch
|
| 34 |
+
|
| 35 |
+
from voxcpm.model import VoxCPMModel
|
| 36 |
+
from voxcpm.training.config import load_yaml_config
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def parse_args():
|
| 40 |
+
parser = argparse.ArgumentParser("VoxCPM full-finetune inference test (no LoRA)")
|
| 41 |
+
parser.add_argument(
|
| 42 |
+
"--config_path",
|
| 43 |
+
type=str,
|
| 44 |
+
required=True,
|
| 45 |
+
help="训练时使用的 YAML 配置路径(至少包含 pretrained_path)",
|
| 46 |
+
)
|
| 47 |
+
parser.add_argument(
|
| 48 |
+
"--ckpt_dir",
|
| 49 |
+
type=str,
|
| 50 |
+
required=True,
|
| 51 |
+
help="全量微调 checkpoint 目录(内含 generator.pth,保存完整 state_dict)",
|
| 52 |
+
)
|
| 53 |
+
parser.add_argument(
|
| 54 |
+
"--text",
|
| 55 |
+
type=str,
|
| 56 |
+
required=True,
|
| 57 |
+
help="待合成的目标文本(target_text)",
|
| 58 |
+
)
|
| 59 |
+
parser.add_argument(
|
| 60 |
+
"--prompt_audio",
|
| 61 |
+
type=str,
|
| 62 |
+
default="",
|
| 63 |
+
help="可选:参考音频路径,用于 voice cloning(不填则为直接 TTS)",
|
| 64 |
+
)
|
| 65 |
+
parser.add_argument(
|
| 66 |
+
"--prompt_text",
|
| 67 |
+
type=str,
|
| 68 |
+
default="",
|
| 69 |
+
help="可选:参考音频对应的文本(与 prompt_audio 搭配使用)",
|
| 70 |
+
)
|
| 71 |
+
parser.add_argument(
|
| 72 |
+
"--output",
|
| 73 |
+
type=str,
|
| 74 |
+
default="ft_test.wav",
|
| 75 |
+
help="输出 wav 文件路径",
|
| 76 |
+
)
|
| 77 |
+
parser.add_argument(
|
| 78 |
+
"--cfg_value",
|
| 79 |
+
type=float,
|
| 80 |
+
default=2.0,
|
| 81 |
+
help="推理时的 CFG scale,与训练 / 官方示例保持一致(默认 2.0)",
|
| 82 |
+
)
|
| 83 |
+
parser.add_argument(
|
| 84 |
+
"--inference_timesteps",
|
| 85 |
+
type=int,
|
| 86 |
+
default=10,
|
| 87 |
+
help="扩散推理步数,默认为 10",
|
| 88 |
+
)
|
| 89 |
+
parser.add_argument(
|
| 90 |
+
"--max_len",
|
| 91 |
+
type=int,
|
| 92 |
+
default=600,
|
| 93 |
+
help="生成阶段的最大步数(对应 _generate 的 max_len)",
|
| 94 |
+
)
|
| 95 |
+
return parser.parse_args()
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def main():
|
| 99 |
+
args = parse_args()
|
| 100 |
+
|
| 101 |
+
# 1. 读取 YAML 配置,拿到 pretrained_path
|
| 102 |
+
cfg = load_yaml_config(args.config_path)
|
| 103 |
+
pretrained_path = cfg["pretrained_path"]
|
| 104 |
+
|
| 105 |
+
# 2. 加载基础模型(无 LoRA),推理模式:training=False,使用 config.dtype,并执行 optimize()
|
| 106 |
+
print(f"[FT Inference] 加载基础模型:{pretrained_path}")
|
| 107 |
+
model = VoxCPMModel.from_local(
|
| 108 |
+
pretrained_path,
|
| 109 |
+
optimize=True,
|
| 110 |
+
training=False,
|
| 111 |
+
lora_config=None,
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
# 3. 从全量微调 ckpt 目录加载 generator.pth(完整 state_dict)
|
| 115 |
+
ckpt_dir = Path(args.ckpt_dir)
|
| 116 |
+
ckpt_path = ckpt_dir / "generator.pth"
|
| 117 |
+
if not ckpt_path.exists():
|
| 118 |
+
raise FileNotFoundError(f"找不到全量微调 checkpoint: {ckpt_path}")
|
| 119 |
+
|
| 120 |
+
print(f"[FT Inference] 从 {ckpt_path} 加载全量微调权重")
|
| 121 |
+
ckpt = torch.load(ckpt_path, map_location="cpu")
|
| 122 |
+
state_dict = ckpt.get("state_dict", ckpt)
|
| 123 |
+
|
| 124 |
+
# 为兼容可能存在的额外键,使用 strict=False,并打印 missing / unexpected 数量
|
| 125 |
+
missing, unexpected = model.load_state_dict(state_dict, strict=False)
|
| 126 |
+
print(f"[FT Inference] 加载完成:missing={len(missing)}, unexpected={len(unexpected)}")
|
| 127 |
+
|
| 128 |
+
# 4. 调用 generate 进行推理
|
| 129 |
+
prompt_wav_path = args.prompt_audio or ""
|
| 130 |
+
prompt_text = args.prompt_text or ""
|
| 131 |
+
|
| 132 |
+
print(f"[FT Inference] 开始合成:text='{args.text}'")
|
| 133 |
+
if prompt_wav_path:
|
| 134 |
+
print(f"[FT Inference] 使用参考音频:{prompt_wav_path}")
|
| 135 |
+
print(f"[FT Inference] 参考文本:{prompt_text}")
|
| 136 |
+
|
| 137 |
+
with torch.inference_mode():
|
| 138 |
+
audio = model.generate(
|
| 139 |
+
target_text=args.text,
|
| 140 |
+
prompt_text=prompt_text,
|
| 141 |
+
prompt_wav_path=prompt_wav_path,
|
| 142 |
+
max_len=args.max_len,
|
| 143 |
+
inference_timesteps=args.inference_timesteps,
|
| 144 |
+
cfg_value=args.cfg_value,
|
| 145 |
+
)
|
| 146 |
+
|
| 147 |
+
# generate 返回的是一维 / 二维 Tensor,这里做一次收缩并落盘
|
| 148 |
+
if isinstance(audio, torch.Tensor):
|
| 149 |
+
if audio.dim() > 1:
|
| 150 |
+
audio = audio.squeeze(0)
|
| 151 |
+
audio_np = audio.cpu().numpy()
|
| 152 |
+
else:
|
| 153 |
+
raise TypeError(f"model.generate 返回类型异常:{type(audio)}")
|
| 154 |
+
|
| 155 |
+
out_path = Path(args.output)
|
| 156 |
+
out_path.parent.mkdir(parents=True, exist_ok=True)
|
| 157 |
+
sf.write(str(out_path), audio_np, model.sample_rate)
|
| 158 |
+
|
| 159 |
+
print(f"[FT Inference] 已保存到:{out_path},时长约 {len(audio_np) / model.sample_rate:.2f}s")
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
if __name__ == "__main__":
|
| 163 |
+
main()
|
| 164 |
+
|
| 165 |
+
|
VoxCPM/scripts/test_voxcpm_lora_infer.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
LoRA 推理测试脚本。
|
| 4 |
+
|
| 5 |
+
用法:
|
| 6 |
+
|
| 7 |
+
python scripts/test_voxcpm_lora_infer.py \
|
| 8 |
+
--config_path conf/voxcpm/voxcpm_finetune_test.yaml \
|
| 9 |
+
--lora_ckpt checkpoints/step_0002000 \
|
| 10 |
+
--text "你好,这是 LoRA 微调后的效果。" \
|
| 11 |
+
--output lora_test.wav
|
| 12 |
+
|
| 13 |
+
带参考音频的音色克隆:
|
| 14 |
+
|
| 15 |
+
python scripts/test_voxcpm_lora_infer.py \
|
| 16 |
+
--config_path conf/voxcpm/voxcpm_finetune_test.yaml \
|
| 17 |
+
--lora_ckpt checkpoints/step_0002000 \
|
| 18 |
+
--text "这是带参考音色的合成效果。" \
|
| 19 |
+
--prompt_audio path/to/ref.wav \
|
| 20 |
+
--prompt_text "参考音频对应的文本" \
|
| 21 |
+
--output lora_clone.wav
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
import argparse
|
| 25 |
+
from pathlib import Path
|
| 26 |
+
|
| 27 |
+
import soundfile as sf
|
| 28 |
+
import torch
|
| 29 |
+
|
| 30 |
+
from voxcpm.model import VoxCPMModel
|
| 31 |
+
from voxcpm.model.voxcpm import LoRAConfig
|
| 32 |
+
from voxcpm.training.config import load_yaml_config
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def parse_args():
|
| 36 |
+
parser = argparse.ArgumentParser("VoxCPM LoRA inference test")
|
| 37 |
+
parser.add_argument(
|
| 38 |
+
"--config_path",
|
| 39 |
+
type=str,
|
| 40 |
+
required=True,
|
| 41 |
+
help="训练时使用的 YAML 配置路径(包含 pretrained_path 和 lora 配置)",
|
| 42 |
+
)
|
| 43 |
+
parser.add_argument(
|
| 44 |
+
"--lora_ckpt",
|
| 45 |
+
type=str,
|
| 46 |
+
required=True,
|
| 47 |
+
help="LoRA checkpoint 目录(内含 generator.pth,仅包含 lora_A / lora_B)",
|
| 48 |
+
)
|
| 49 |
+
parser.add_argument(
|
| 50 |
+
"--text",
|
| 51 |
+
type=str,
|
| 52 |
+
required=True,
|
| 53 |
+
help="待合成的目标文本(target_text)",
|
| 54 |
+
)
|
| 55 |
+
parser.add_argument(
|
| 56 |
+
"--prompt_audio",
|
| 57 |
+
type=str,
|
| 58 |
+
default="",
|
| 59 |
+
help="可选:参考音频路径,用于 voice cloning(不填则为直接 TTS)",
|
| 60 |
+
)
|
| 61 |
+
parser.add_argument(
|
| 62 |
+
"--prompt_text",
|
| 63 |
+
type=str,
|
| 64 |
+
default="",
|
| 65 |
+
help="可选:参考音频对应的文本(与 prompt_audio 搭配使用)",
|
| 66 |
+
)
|
| 67 |
+
parser.add_argument(
|
| 68 |
+
"--output",
|
| 69 |
+
type=str,
|
| 70 |
+
default="lora_test.wav",
|
| 71 |
+
help="输出 wav 文件路径",
|
| 72 |
+
)
|
| 73 |
+
parser.add_argument(
|
| 74 |
+
"--cfg_value",
|
| 75 |
+
type=float,
|
| 76 |
+
default=2.0,
|
| 77 |
+
help="推理时的 CFG scale,与训练 / 官方示例保持一致(默认 2.0)",
|
| 78 |
+
)
|
| 79 |
+
parser.add_argument(
|
| 80 |
+
"--inference_timesteps",
|
| 81 |
+
type=int,
|
| 82 |
+
default=10,
|
| 83 |
+
help="扩散推理步数,默认为 10",
|
| 84 |
+
)
|
| 85 |
+
parser.add_argument(
|
| 86 |
+
"--max_len",
|
| 87 |
+
type=int,
|
| 88 |
+
default=600,
|
| 89 |
+
help="生成阶段的最大步数(对应 _generate 的 max_len)",
|
| 90 |
+
)
|
| 91 |
+
return parser.parse_args()
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def main():
|
| 95 |
+
args = parse_args()
|
| 96 |
+
|
| 97 |
+
# 1. 读取 YAML 配置
|
| 98 |
+
cfg = load_yaml_config(args.config_path)
|
| 99 |
+
pretrained_path = cfg["pretrained_path"]
|
| 100 |
+
lora_cfg_dict = cfg.get("lora", {}) or {}
|
| 101 |
+
lora_cfg = LoRAConfig(**lora_cfg_dict) if lora_cfg_dict else None
|
| 102 |
+
|
| 103 |
+
# 2. 加载基础模型(包含 LoRA 结构,并执行 torch.compile)
|
| 104 |
+
print(f"[1/3] 加载基础模型:{pretrained_path}")
|
| 105 |
+
model = VoxCPMModel.from_local(
|
| 106 |
+
pretrained_path,
|
| 107 |
+
optimize=True, # 先 compile,load_lora_weights 使用 named_parameters 兼容
|
| 108 |
+
training=False,
|
| 109 |
+
lora_config=lora_cfg,
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
# 调试:检查 compile 后 DiT 的参数路径
|
| 113 |
+
dit_params = [n for n, _ in model.named_parameters() if 'feat_decoder' in n and 'lora' in n]
|
| 114 |
+
print(f"[DEBUG] compile 后 DiT LoRA 参数路径 (前3个): {dit_params[:3]}")
|
| 115 |
+
|
| 116 |
+
# 3. 加载 LoRA 权重(在 compile 后也能正常工作)
|
| 117 |
+
ckpt_dir = Path(args.lora_ckpt)
|
| 118 |
+
if not ckpt_dir.exists():
|
| 119 |
+
raise FileNotFoundError(f"找不到 LoRA checkpoint: {ckpt_dir}")
|
| 120 |
+
|
| 121 |
+
print(f"[2/3] 加载 LoRA 权重:{ckpt_dir}")
|
| 122 |
+
loaded, skipped = model.load_lora_weights(str(ckpt_dir))
|
| 123 |
+
print(f" 已加载 {len(loaded)} 个参数")
|
| 124 |
+
if skipped:
|
| 125 |
+
print(f"[WARNING] 跳过 {len(skipped)} 个参数")
|
| 126 |
+
print(f" 跳过的 key (前5个): {skipped[:5]}")
|
| 127 |
+
|
| 128 |
+
# 4. 合成语音
|
| 129 |
+
prompt_wav_path = args.prompt_audio or ""
|
| 130 |
+
prompt_text = args.prompt_text or ""
|
| 131 |
+
out_path = Path(args.output)
|
| 132 |
+
out_path.parent.mkdir(parents=True, exist_ok=True)
|
| 133 |
+
|
| 134 |
+
print(f"\n[3/3] 开始合成测试...")
|
| 135 |
+
|
| 136 |
+
# === 测试 1: 使用 LoRA ===
|
| 137 |
+
print(f"\n [Test 1] 使用 LoRA 合成...")
|
| 138 |
+
with torch.inference_mode():
|
| 139 |
+
audio = model.generate(
|
| 140 |
+
target_text=args.text,
|
| 141 |
+
prompt_text=prompt_text,
|
| 142 |
+
prompt_wav_path=prompt_wav_path,
|
| 143 |
+
max_len=args.max_len,
|
| 144 |
+
inference_timesteps=args.inference_timesteps,
|
| 145 |
+
cfg_value=args.cfg_value,
|
| 146 |
+
)
|
| 147 |
+
audio_np = audio.squeeze(0).cpu().numpy() if audio.dim() > 1 else audio.cpu().numpy()
|
| 148 |
+
lora_output = out_path.with_stem(out_path.stem + "_with_lora")
|
| 149 |
+
sf.write(str(lora_output), audio_np, model.sample_rate)
|
| 150 |
+
print(f" 已保存:{lora_output},时长 {len(audio_np) / model.sample_rate:.2f}s")
|
| 151 |
+
|
| 152 |
+
# === 测试 2: 禁用 LoRA(通过 set_lora_enabled) ===
|
| 153 |
+
print(f"\n [Test 2] 禁用 LoRA (set_lora_enabled=False)...")
|
| 154 |
+
model.set_lora_enabled(False)
|
| 155 |
+
with torch.inference_mode():
|
| 156 |
+
audio = model.generate(
|
| 157 |
+
target_text=args.text,
|
| 158 |
+
prompt_text=prompt_text,
|
| 159 |
+
prompt_wav_path=prompt_wav_path,
|
| 160 |
+
max_len=args.max_len,
|
| 161 |
+
inference_timesteps=args.inference_timesteps,
|
| 162 |
+
cfg_value=args.cfg_value,
|
| 163 |
+
)
|
| 164 |
+
audio_np = audio.squeeze(0).cpu().numpy() if audio.dim() > 1 else audio.cpu().numpy()
|
| 165 |
+
disabled_output = out_path.with_stem(out_path.stem + "_lora_disabled")
|
| 166 |
+
sf.write(str(disabled_output), audio_np, model.sample_rate)
|
| 167 |
+
print(f" 已保存:{disabled_output},时长 {len(audio_np) / model.sample_rate:.2f}s")
|
| 168 |
+
|
| 169 |
+
# === 测试 3: 重新启用 LoRA ===
|
| 170 |
+
print(f"\n [Test 3] 重新启用 LoRA (set_lora_enabled=True)...")
|
| 171 |
+
model.set_lora_enabled(True)
|
| 172 |
+
with torch.inference_mode():
|
| 173 |
+
audio = model.generate(
|
| 174 |
+
target_text=args.text,
|
| 175 |
+
prompt_text=prompt_text,
|
| 176 |
+
prompt_wav_path=prompt_wav_path,
|
| 177 |
+
max_len=args.max_len,
|
| 178 |
+
inference_timesteps=args.inference_timesteps,
|
| 179 |
+
cfg_value=args.cfg_value,
|
| 180 |
+
)
|
| 181 |
+
audio_np = audio.squeeze(0).cpu().numpy() if audio.dim() > 1 else audio.cpu().numpy()
|
| 182 |
+
reenabled_output = out_path.with_stem(out_path.stem + "_lora_reenabled")
|
| 183 |
+
sf.write(str(reenabled_output), audio_np, model.sample_rate)
|
| 184 |
+
print(f" 已保存:{reenabled_output},时长 {len(audio_np) / model.sample_rate:.2f}s")
|
| 185 |
+
|
| 186 |
+
# === 测试 4: 卸载 LoRA(reset_lora_weights) ===
|
| 187 |
+
print(f"\n [Test 4] 卸载 LoRA (reset_lora_weights)...")
|
| 188 |
+
model.reset_lora_weights()
|
| 189 |
+
with torch.inference_mode():
|
| 190 |
+
audio = model.generate(
|
| 191 |
+
target_text=args.text,
|
| 192 |
+
prompt_text=prompt_text,
|
| 193 |
+
prompt_wav_path=prompt_wav_path,
|
| 194 |
+
max_len=args.max_len,
|
| 195 |
+
inference_timesteps=args.inference_timesteps,
|
| 196 |
+
cfg_value=args.cfg_value,
|
| 197 |
+
)
|
| 198 |
+
audio_np = audio.squeeze(0).cpu().numpy() if audio.dim() > 1 else audio.cpu().numpy()
|
| 199 |
+
reset_output = out_path.with_stem(out_path.stem + "_lora_reset")
|
| 200 |
+
sf.write(str(reset_output), audio_np, model.sample_rate)
|
| 201 |
+
print(f" 已保存:{reset_output},时长 {len(audio_np) / model.sample_rate:.2f}s")
|
| 202 |
+
|
| 203 |
+
# === 测试 5: 热加载 LoRA(重新加载权重) ===
|
| 204 |
+
print(f"\n [Test 5] 热加载 LoRA (load_lora_weights)...")
|
| 205 |
+
loaded, _ = model.load_lora_weights(str(ckpt_dir))
|
| 206 |
+
print(f" 重新加载了 {len(loaded)} 个参数")
|
| 207 |
+
with torch.inference_mode():
|
| 208 |
+
audio = model.generate(
|
| 209 |
+
target_text=args.text,
|
| 210 |
+
prompt_text=prompt_text,
|
| 211 |
+
prompt_wav_path=prompt_wav_path,
|
| 212 |
+
max_len=args.max_len,
|
| 213 |
+
inference_timesteps=args.inference_timesteps,
|
| 214 |
+
cfg_value=args.cfg_value,
|
| 215 |
+
)
|
| 216 |
+
audio_np = audio.squeeze(0).cpu().numpy() if audio.dim() > 1 else audio.cpu().numpy()
|
| 217 |
+
reload_output = out_path.with_stem(out_path.stem + "_lora_reloaded")
|
| 218 |
+
sf.write(str(reload_output), audio_np, model.sample_rate)
|
| 219 |
+
print(f" 已保存:{reload_output},时长 {len(audio_np) / model.sample_rate:.2f}s")
|
| 220 |
+
|
| 221 |
+
print(f"\n[完成] 所有测试完成!")
|
| 222 |
+
print(f" - with_lora: {lora_output}")
|
| 223 |
+
print(f" - lora_disabled: {disabled_output}")
|
| 224 |
+
print(f" - lora_reenabled: {reenabled_output}")
|
| 225 |
+
print(f" - lora_reset: {reset_output}")
|
| 226 |
+
print(f" - lora_reloaded: {reload_output}")
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
if __name__ == "__main__":
|
| 230 |
+
main()
|
| 231 |
+
|
| 232 |
+
|
VoxCPM/scripts/train_voxcpm_finetune.py
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
|
| 3 |
+
import itertools
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from typing import Dict, Optional
|
| 6 |
+
|
| 7 |
+
import argbind
|
| 8 |
+
import torch
|
| 9 |
+
from tensorboardX import SummaryWriter
|
| 10 |
+
from torch.optim import AdamW
|
| 11 |
+
from transformers import get_cosine_schedule_with_warmup
|
| 12 |
+
|
| 13 |
+
from voxcpm.model import VoxCPMModel
|
| 14 |
+
from voxcpm.model.voxcpm import LoRAConfig
|
| 15 |
+
from voxcpm.training import (
|
| 16 |
+
Accelerator,
|
| 17 |
+
BatchProcessor,
|
| 18 |
+
TrainingTracker,
|
| 19 |
+
build_dataloader,
|
| 20 |
+
load_audio_text_datasets,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@argbind.bind(without_prefix=True)
|
| 25 |
+
def train(
|
| 26 |
+
pretrained_path: str,
|
| 27 |
+
train_manifest: str,
|
| 28 |
+
val_manifest: str = "",
|
| 29 |
+
sample_rate: int = 16_000,
|
| 30 |
+
batch_size: int = 1,
|
| 31 |
+
grad_accum_steps: int = 1,
|
| 32 |
+
num_workers: int = 2,
|
| 33 |
+
num_iters: int = 100_000,
|
| 34 |
+
log_interval: int = 100,
|
| 35 |
+
valid_interval: int = 1_000,
|
| 36 |
+
save_interval: int = 10_000,
|
| 37 |
+
learning_rate: float = 1e-4,
|
| 38 |
+
weight_decay: float = 1e-2,
|
| 39 |
+
warmup_steps: int = 1_000,
|
| 40 |
+
max_steps: int = 100_000,
|
| 41 |
+
max_batch_tokens: int = 0,
|
| 42 |
+
save_path: str = "checkpoints",
|
| 43 |
+
tensorboard: str = "",
|
| 44 |
+
lambdas: Dict[str, float] = {"loss/diff": 1.0, "loss/stop": 1.0},
|
| 45 |
+
lora: dict = None,
|
| 46 |
+
config_path: str = "",
|
| 47 |
+
):
|
| 48 |
+
_ = config_path
|
| 49 |
+
accelerator = Accelerator(amp=True)
|
| 50 |
+
|
| 51 |
+
save_dir = Path(save_path)
|
| 52 |
+
save_dir.mkdir(parents=True, exist_ok=True)
|
| 53 |
+
tb_dir = Path(tensorboard) if tensorboard else save_dir / "logs"
|
| 54 |
+
tb_dir.mkdir(parents=True, exist_ok=True)
|
| 55 |
+
|
| 56 |
+
writer = SummaryWriter(log_dir=str(tb_dir)) if accelerator.rank == 0 else None
|
| 57 |
+
tracker = TrainingTracker(writer=writer, log_file=str(save_dir / "train.log"), rank=accelerator.rank)
|
| 58 |
+
|
| 59 |
+
base_model = VoxCPMModel.from_local(pretrained_path, optimize=False, training=True, lora_config=LoRAConfig(**lora) if lora else None)
|
| 60 |
+
tokenizer = base_model.text_tokenizer
|
| 61 |
+
|
| 62 |
+
train_ds, val_ds = load_audio_text_datasets(
|
| 63 |
+
train_manifest=train_manifest,
|
| 64 |
+
val_manifest=val_manifest,
|
| 65 |
+
sample_rate=sample_rate,
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
def tokenize(batch):
|
| 69 |
+
text_list = batch["text"]
|
| 70 |
+
text_ids = [tokenizer(text) for text in text_list]
|
| 71 |
+
return {"text_ids": text_ids}
|
| 72 |
+
|
| 73 |
+
train_ds = train_ds.map(tokenize, batched=True, remove_columns=["text"])
|
| 74 |
+
if val_ds is not None:
|
| 75 |
+
val_ds = val_ds.map(tokenize, batched=True, remove_columns=["text"])
|
| 76 |
+
|
| 77 |
+
dataset_cnt = int(max(train_ds["dataset_id"])) + 1 if "dataset_id" in train_ds.column_names else 1
|
| 78 |
+
num_train_samples = len(train_ds)
|
| 79 |
+
|
| 80 |
+
# ------------------------------------------------------------------ #
|
| 81 |
+
# 可选:按预估 token 数过滤超长样本,避免单个样本撑爆显存
|
| 82 |
+
# max_batch_tokens > 0 时启用:
|
| 83 |
+
# 每个样本的最大长度 = max_batch_tokens // batch_size
|
| 84 |
+
# 超过该长度的样本将被丢弃(train_ds 过滤)
|
| 85 |
+
# ------------------------------------------------------------------ #
|
| 86 |
+
if max_batch_tokens and max_batch_tokens > 0:
|
| 87 |
+
from voxcpm.training.data import compute_sample_lengths
|
| 88 |
+
|
| 89 |
+
est_lengths = compute_sample_lengths(
|
| 90 |
+
train_ds,
|
| 91 |
+
audio_vae_fps=25,
|
| 92 |
+
patch_size=base_model.config.patch_size,
|
| 93 |
+
)
|
| 94 |
+
max_sample_len = max_batch_tokens // batch_size if batch_size > 0 else max(est_lengths)
|
| 95 |
+
keep_indices = [i for i, L in enumerate(est_lengths) if L <= max_sample_len]
|
| 96 |
+
|
| 97 |
+
if len(keep_indices) < len(train_ds) and accelerator.rank == 0:
|
| 98 |
+
tracker.print(
|
| 99 |
+
f"Filtering {len(train_ds) - len(keep_indices)} / {len(train_ds)} "
|
| 100 |
+
f"training samples longer than {max_sample_len} tokens "
|
| 101 |
+
f"(max_batch_tokens={max_batch_tokens})."
|
| 102 |
+
)
|
| 103 |
+
train_ds = train_ds.select(keep_indices)
|
| 104 |
+
|
| 105 |
+
train_loader = build_dataloader(
|
| 106 |
+
train_ds,
|
| 107 |
+
accelerator=accelerator,
|
| 108 |
+
batch_size=batch_size,
|
| 109 |
+
num_workers=num_workers,
|
| 110 |
+
drop_last=True,
|
| 111 |
+
)
|
| 112 |
+
val_loader = (
|
| 113 |
+
build_dataloader(
|
| 114 |
+
val_ds,
|
| 115 |
+
accelerator=accelerator,
|
| 116 |
+
batch_size=batch_size,
|
| 117 |
+
num_workers=num_workers,
|
| 118 |
+
drop_last=False,
|
| 119 |
+
)
|
| 120 |
+
if val_ds is not None
|
| 121 |
+
else None
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
model = accelerator.prepare_model(base_model)
|
| 125 |
+
unwrapped_model = accelerator.unwrap(model)
|
| 126 |
+
unwrapped_model.train()
|
| 127 |
+
|
| 128 |
+
batch_processor = BatchProcessor(
|
| 129 |
+
config=unwrapped_model.config,
|
| 130 |
+
audio_vae=unwrapped_model.audio_vae,
|
| 131 |
+
dataset_cnt=dataset_cnt,
|
| 132 |
+
device=accelerator.device,
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
for name, param in model.named_parameters():
|
| 136 |
+
print(name, param.requires_grad)
|
| 137 |
+
|
| 138 |
+
optimizer = AdamW(
|
| 139 |
+
(p for p in model.parameters() if p.requires_grad),
|
| 140 |
+
lr=learning_rate,
|
| 141 |
+
weight_decay=weight_decay,
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
# 使用 transformers 的 cosine + warmup 调度器:
|
| 145 |
+
# - num_warmup_steps: 预热步数
|
| 146 |
+
# - num_training_steps: 计划的总训练步数(按 outer step 计数)
|
| 147 |
+
total_training_steps = max_steps if max_steps > 0 else num_iters
|
| 148 |
+
scheduler = get_cosine_schedule_with_warmup(
|
| 149 |
+
optimizer,
|
| 150 |
+
num_warmup_steps=warmup_steps,
|
| 151 |
+
num_training_steps=total_training_steps,
|
| 152 |
+
)
|
| 153 |
+
|
| 154 |
+
train_iter = iter(itertools.cycle(train_loader))
|
| 155 |
+
grad_accum_steps = max(int(grad_accum_steps), 1)
|
| 156 |
+
|
| 157 |
+
with tracker.live():
|
| 158 |
+
for step in range(num_iters):
|
| 159 |
+
tracker.step = step
|
| 160 |
+
optimizer.zero_grad(set_to_none=True)
|
| 161 |
+
|
| 162 |
+
# 梯度累积:在多个 micro-batch 上累积梯度,再进行一次优化步
|
| 163 |
+
loss_dict = {}
|
| 164 |
+
for micro_step in range(grad_accum_steps):
|
| 165 |
+
batch = next(train_iter)
|
| 166 |
+
processed = batch_processor(batch)
|
| 167 |
+
|
| 168 |
+
with accelerator.autocast(dtype=torch.bfloat16):
|
| 169 |
+
outputs = model(
|
| 170 |
+
processed["text_tokens"],
|
| 171 |
+
processed["text_mask"],
|
| 172 |
+
processed["audio_feats"],
|
| 173 |
+
processed["audio_mask"],
|
| 174 |
+
processed["loss_mask"],
|
| 175 |
+
processed["position_ids"],
|
| 176 |
+
processed["labels"],
|
| 177 |
+
progress=step / max(1, num_iters),
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
total_loss = 0.0
|
| 181 |
+
for key, value in outputs.items():
|
| 182 |
+
if key.startswith("loss/"):
|
| 183 |
+
weight = lambdas.get(key, 1.0)
|
| 184 |
+
loss_value = value * weight / grad_accum_steps
|
| 185 |
+
total_loss = total_loss + loss_value
|
| 186 |
+
# 记录最后一个 micro-batch 的原始 loss,便于日志查看
|
| 187 |
+
loss_dict[key] = value.detach()
|
| 188 |
+
|
| 189 |
+
# 对当前 micro-batch 累积梯度(已按 grad_accum_steps 归一化)
|
| 190 |
+
accelerator.backward(total_loss)
|
| 191 |
+
|
| 192 |
+
# 在所有 micro-batch 反向完成后,再做一次 unscale / grad_norm / step
|
| 193 |
+
scaler = getattr(accelerator, "scaler", None)
|
| 194 |
+
if scaler is not None:
|
| 195 |
+
scaler.unscale_(optimizer)
|
| 196 |
+
# 使用极大 max_norm 复用实现,仅做 grad_norm 统计而不实际裁剪
|
| 197 |
+
grad_norm = torch.nn.utils.clip_grad_norm_(unwrapped_model.parameters(), max_norm=1e9)
|
| 198 |
+
|
| 199 |
+
accelerator.step(optimizer)
|
| 200 |
+
accelerator.update()
|
| 201 |
+
scheduler.step()
|
| 202 |
+
|
| 203 |
+
if step % log_interval == 0:
|
| 204 |
+
loss_values = {k: v.item() if isinstance(v, torch.Tensor) else float(v) for k, v in loss_dict.items()}
|
| 205 |
+
loss_values["lr"] = float(optimizer.param_groups[0]["lr"])
|
| 206 |
+
# 近似当前 epoch:已见样本数 / 训练集样本数(考虑梯度累积和 batch_size)
|
| 207 |
+
epoch = (step * grad_accum_steps * batch_size) / max(1, num_train_samples)
|
| 208 |
+
loss_values["epoch"] = float(epoch)
|
| 209 |
+
loss_values["grad_norm"] = float(grad_norm)
|
| 210 |
+
tracker.log_metrics(loss_values, split="train")
|
| 211 |
+
|
| 212 |
+
if val_loader is not None and step % valid_interval == 0 and step != 0:
|
| 213 |
+
validate(model, val_loader, batch_processor, accelerator, tracker, lambdas)
|
| 214 |
+
|
| 215 |
+
if step % save_interval == 0 and accelerator.rank == 0:
|
| 216 |
+
save_checkpoint(model, optimizer, scheduler, save_dir, step)
|
| 217 |
+
|
| 218 |
+
if accelerator.rank == 0:
|
| 219 |
+
save_checkpoint(model, optimizer, scheduler, save_dir, num_iters)
|
| 220 |
+
if writer:
|
| 221 |
+
writer.close()
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def validate(model, val_loader, batch_processor, accelerator, tracker, lambdas):
|
| 225 |
+
model.eval()
|
| 226 |
+
losses = []
|
| 227 |
+
with torch.no_grad():
|
| 228 |
+
for batch in itertools.islice(val_loader, 0, 10):
|
| 229 |
+
processed = batch_processor(batch)
|
| 230 |
+
with accelerator.autocast(dtype=torch.bfloat16):
|
| 231 |
+
outputs = model(
|
| 232 |
+
processed["text_tokens"],
|
| 233 |
+
processed["text_mask"],
|
| 234 |
+
processed["audio_feats"],
|
| 235 |
+
processed["audio_mask"],
|
| 236 |
+
processed["loss_mask"],
|
| 237 |
+
processed["position_ids"],
|
| 238 |
+
processed["labels"],
|
| 239 |
+
progress=0.0,
|
| 240 |
+
sample_generate=False,
|
| 241 |
+
)
|
| 242 |
+
total = 0.0
|
| 243 |
+
for key, value in outputs.items():
|
| 244 |
+
if key.startswith("loss/"):
|
| 245 |
+
total += lambdas.get(key, 1.0) * value
|
| 246 |
+
losses.append(total.detach())
|
| 247 |
+
if losses:
|
| 248 |
+
mean_loss = torch.stack(losses).mean()
|
| 249 |
+
tracker.log_metrics({"loss": mean_loss.item()}, split="val")
|
| 250 |
+
model.train()
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def save_checkpoint(model, optimizer, scheduler, save_dir: Path, step: int):
|
| 254 |
+
save_dir.mkdir(parents=True, exist_ok=True)
|
| 255 |
+
tag = "latest" if step == 0 else f"step_{step:07d}"
|
| 256 |
+
folder = save_dir / tag
|
| 257 |
+
folder.mkdir(parents=True, exist_ok=True)
|
| 258 |
+
# 根据是否启用 LoRA 决定保存哪些权重:
|
| 259 |
+
# - 启用 LoRA,则仅保存 LoRA 参数(lora_A / lora_B)
|
| 260 |
+
# - 否则保存完整模型权重
|
| 261 |
+
unwrapped = model.module if hasattr(model, "module") else model
|
| 262 |
+
full_state = unwrapped.state_dict()
|
| 263 |
+
lora_cfg = unwrapped.lora_config
|
| 264 |
+
if lora_cfg is not None:
|
| 265 |
+
state_dict = {k: v for k, v in full_state.items() if ("lora_A" in k or "lora_B" in k)}
|
| 266 |
+
else:
|
| 267 |
+
state_dict = full_state
|
| 268 |
+
|
| 269 |
+
torch.save({"state_dict": state_dict}, folder / "generator.pth")
|
| 270 |
+
torch.save(optimizer.state_dict(), folder / "optimizer.pth")
|
| 271 |
+
torch.save(scheduler.state_dict(), folder / "scheduler.pth")
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
if __name__ == "__main__":
|
| 275 |
+
from voxcpm.training.config import load_yaml_config
|
| 276 |
+
|
| 277 |
+
args = argbind.parse_args()
|
| 278 |
+
config_file = args.get("config_path")
|
| 279 |
+
# 如果提供了 YAML 配置文件,则直接用 YAML 的参数调用 train
|
| 280 |
+
if config_file:
|
| 281 |
+
yaml_args = load_yaml_config(config_file)
|
| 282 |
+
train(**yaml_args)
|
| 283 |
+
else:
|
| 284 |
+
# 否则使用命令行参数(argbind 解析)调用 train
|
| 285 |
+
with argbind.scope(args):
|
| 286 |
+
train()
|
| 287 |
+
|
VoxCPM/src/voxcpm.egg-info/PKG-INFO
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: voxcpm
|
| 3 |
+
Version: 1.0.5.post0+gd1bb6aaf4.d20251128
|
| 4 |
+
Summary: VoxCPM: Tokenizer-Free TTS for Context-Aware Speech Generation and True-to-Life Voice Cloning
|
| 5 |
+
Author-email: OpenBMB <openbmb@gmail.com>
|
| 6 |
+
Maintainer-email: OpenBMB <openbmb@gmail.com>
|
| 7 |
+
License-Expression: Apache-2.0
|
| 8 |
+
Project-URL: Homepage, https://github.com/OpenBMB/VoxCPM
|
| 9 |
+
Project-URL: Repository, https://github.com/OpenBMB/VoxCPM.git
|
| 10 |
+
Project-URL: Documentation, https://github.com/OpenBMB/VoxCPM#readme
|
| 11 |
+
Project-URL: Bug Tracker, https://github.com/OpenBMB/VoxCPM/issues
|
| 12 |
+
Keywords: voxcpm,text-to-speech,tts,speech-synthesis,voice-cloning,ai,deep-learning,pytorch
|
| 13 |
+
Classifier: Development Status :: 3 - Alpha
|
| 14 |
+
Classifier: Intended Audience :: Developers
|
| 15 |
+
Classifier: Operating System :: OS Independent
|
| 16 |
+
Classifier: Programming Language :: Python :: 3
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 19 |
+
Requires-Python: >=3.10
|
| 20 |
+
Description-Content-Type: text/markdown
|
| 21 |
+
License-File: LICENSE
|
| 22 |
+
Requires-Dist: torch>=2.5.0
|
| 23 |
+
Requires-Dist: torchaudio>=2.5.0
|
| 24 |
+
Requires-Dist: transformers>=4.36.2
|
| 25 |
+
Requires-Dist: einops
|
| 26 |
+
Requires-Dist: gradio
|
| 27 |
+
Requires-Dist: inflect
|
| 28 |
+
Requires-Dist: addict
|
| 29 |
+
Requires-Dist: wetext
|
| 30 |
+
Requires-Dist: modelscope>=1.22.0
|
| 31 |
+
Requires-Dist: datasets<4,>=3
|
| 32 |
+
Requires-Dist: huggingface-hub
|
| 33 |
+
Requires-Dist: pydantic
|
| 34 |
+
Requires-Dist: tqdm
|
| 35 |
+
Requires-Dist: simplejson
|
| 36 |
+
Requires-Dist: sortedcontainers
|
| 37 |
+
Requires-Dist: soundfile
|
| 38 |
+
Requires-Dist: funasr
|
| 39 |
+
Requires-Dist: spaces
|
| 40 |
+
Requires-Dist: argbind
|
| 41 |
+
Requires-Dist: tensorboardX
|
| 42 |
+
Provides-Extra: dev
|
| 43 |
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
| 44 |
+
Requires-Dist: pytest-cov>=2.0; extra == "dev"
|
| 45 |
+
Requires-Dist: black>=21.0; extra == "dev"
|
| 46 |
+
Requires-Dist: flake8>=3.8; extra == "dev"
|
| 47 |
+
Requires-Dist: mypy>=0.800; extra == "dev"
|
| 48 |
+
Requires-Dist: pre-commit>=2.0; extra == "dev"
|
| 49 |
+
Dynamic: license-file
|
| 50 |
+
|
| 51 |
+
## 🎙️ VoxCPM: Tokenizer-Free TTS for Context-Aware Speech Generation and True-to-Life Voice Cloning
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
[](https://github.com/OpenBMB/VoxCPM/) [](https://arxiv.org/abs/2509.24650) [](https://huggingface.co/openbmb/VoxCPM-0.5B) [](https://modelscope.cn/models/OpenBMB/VoxCPM-0.5B) [](https://huggingface.co/spaces/OpenBMB/VoxCPM-Demo) [](https://openbmb.github.io/VoxCPM-demopage)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
<div align="center">
|
| 59 |
+
<img src="assets/voxcpm_logo.png" alt="VoxCPM Logo" width="40%">
|
| 60 |
+
</div>
|
| 61 |
+
|
| 62 |
+
<div align="center">
|
| 63 |
+
|
| 64 |
+
👋 Contact us on [WeChat](assets/wechat.png)
|
| 65 |
+
|
| 66 |
+
</div>
|
| 67 |
+
|
| 68 |
+
## News
|
| 69 |
+
* [2025.09.30] 🔥 🔥 🔥 We Release VoxCPM [Technical Report](https://arxiv.org/abs/2509.24650)!
|
| 70 |
+
* [2025.09.16] 🔥 🔥 🔥 We Open Source the VoxCPM-0.5B [weights](https://huggingface.co/openbmb/VoxCPM-0.5B)!
|
| 71 |
+
* [2025.09.16] 🎉 🎉 🎉 We Provide the [Gradio PlayGround](https://huggingface.co/spaces/OpenBMB/VoxCPM-Demo) for VoxCPM-0.5B, try it now!
|
| 72 |
+
|
| 73 |
+
## Overview
|
| 74 |
+
|
| 75 |
+
VoxCPM is a novel tokenizer-free Text-to-Speech (TTS) system that redefines realism in speech synthesis. By modeling speech in a continuous space, it overcomes the limitations of discrete tokenization and enables two flagship capabilities: context-aware speech generation and true-to-life zero-shot voice cloning.
|
| 76 |
+
|
| 77 |
+
Unlike mainstream approaches that convert speech to discrete tokens, VoxCPM uses an end-to-end diffusion autoregressive architecture that directly generates continuous speech representations from text. Built on [MiniCPM-4](https://huggingface.co/openbmb/MiniCPM4-0.5B) backbone, it achieves implicit semantic-acoustic decoupling through hierachical language modeling and FSQ constraints, greatly enhancing both expressiveness and generation stability.
|
| 78 |
+
|
| 79 |
+
<div align="center">
|
| 80 |
+
<img src="assets/voxcpm_model.png" alt="VoxCPM Model Architecture" width="90%">
|
| 81 |
+
</div>
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
### 🚀 Key Features
|
| 85 |
+
- **Context-Aware, Expressive Speech Generation** - VoxCPM comprehends text to infer and generate appropriate prosody, delivering speech with remarkable expressiveness and natural flow. It spontaneously adapts speaking style based on content, producing highly fitting vocal expression trained on a massive 1.8 million-hour bilingual corpus.
|
| 86 |
+
- **True-to-Life Voice Cloning** - With only a short reference audio clip, VoxCPM performs accurate zero-shot voice cloning, capturing not only the speaker’s timbre but also fine-grained characteristics such as accent, emotional tone, rhythm, and pacing to create a faithful and natural replica.
|
| 87 |
+
- **High-Efficiency Synthesis** - VoxCPM supports streaming synthesis with a Real-Time Factor (RTF) as low as 0.17 on a consumer-grade NVIDIA RTX 4090 GPU, making it possible for real-time applications.
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
## Quick Start
|
| 94 |
+
|
| 95 |
+
### 🔧 Install from PyPI
|
| 96 |
+
``` sh
|
| 97 |
+
pip install voxcpm
|
| 98 |
+
```
|
| 99 |
+
### 1. Model Download (Optional)
|
| 100 |
+
By default, when you first run the script, the model will be downloaded automatically, but you can also download the model in advance.
|
| 101 |
+
- Download VoxCPM-0.5B
|
| 102 |
+
```
|
| 103 |
+
from huggingface_hub import snapshot_download
|
| 104 |
+
snapshot_download("openbmb/VoxCPM-0.5B")
|
| 105 |
+
```
|
| 106 |
+
- Download ZipEnhancer and SenseVoice-Small. We use ZipEnhancer to enhance speech prompts and SenseVoice-Small for speech prompt ASR in the web demo.
|
| 107 |
+
```
|
| 108 |
+
from modelscope import snapshot_download
|
| 109 |
+
snapshot_download('iic/speech_zipenhancer_ans_multiloss_16k_base')
|
| 110 |
+
snapshot_download('iic/SenseVoiceSmall')
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
### 2. Basic Usage
|
| 114 |
+
```python
|
| 115 |
+
import soundfile as sf
|
| 116 |
+
import numpy as np
|
| 117 |
+
from voxcpm import VoxCPM
|
| 118 |
+
|
| 119 |
+
model = VoxCPM.from_pretrained("openbmb/VoxCPM-0.5B")
|
| 120 |
+
|
| 121 |
+
# Non-streaming
|
| 122 |
+
wav = model.generate(
|
| 123 |
+
text="VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech.",
|
| 124 |
+
prompt_wav_path=None, # optional: path to a prompt speech for voice cloning
|
| 125 |
+
prompt_text=None, # optional: reference text
|
| 126 |
+
cfg_value=2.0, # LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse
|
| 127 |
+
inference_timesteps=10, # LocDiT inference timesteps, higher for better result, lower for fast speed
|
| 128 |
+
normalize=True, # enable external TN tool
|
| 129 |
+
denoise=True, # enable external Denoise tool
|
| 130 |
+
retry_badcase=True, # enable retrying mode for some bad cases (unstoppable)
|
| 131 |
+
retry_badcase_max_times=3, # maximum retrying times
|
| 132 |
+
retry_badcase_ratio_threshold=6.0, # maximum length restriction for bad case detection (simple but effective), it could be adjusted for slow pace speech
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
sf.write("output.wav", wav, 16000)
|
| 136 |
+
print("saved: output.wav")
|
| 137 |
+
|
| 138 |
+
# Streaming
|
| 139 |
+
chunks = []
|
| 140 |
+
for chunk in model.generate_streaming(
|
| 141 |
+
text = "Streaming text to speech is easy with VoxCPM!",
|
| 142 |
+
# supports same args as above
|
| 143 |
+
):
|
| 144 |
+
chunks.append(chunk)
|
| 145 |
+
wav = np.concatenate(chunks)
|
| 146 |
+
|
| 147 |
+
sf.write("output_streaming.wav", wav, 16000)
|
| 148 |
+
print("saved: output_streaming.wav")
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
### 3. CLI Usage
|
| 152 |
+
|
| 153 |
+
After installation, the entry point is `voxcpm` (or use `python -m voxcpm.cli`).
|
| 154 |
+
|
| 155 |
+
```bash
|
| 156 |
+
# 1) Direct synthesis (single text)
|
| 157 |
+
voxcpm --text "VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech." --output out.wav
|
| 158 |
+
|
| 159 |
+
# 2) Voice cloning (reference audio + transcript)
|
| 160 |
+
voxcpm --text "VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech." \
|
| 161 |
+
--prompt-audio path/to/voice.wav \
|
| 162 |
+
--prompt-text "reference transcript" \
|
| 163 |
+
--output out.wav \
|
| 164 |
+
--denoise
|
| 165 |
+
|
| 166 |
+
# (Optinal) Voice cloning (reference audio + transcript file)
|
| 167 |
+
voxcpm --text "VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech." \
|
| 168 |
+
--prompt-audio path/to/voice.wav \
|
| 169 |
+
--prompt-file "/path/to/text-file" \
|
| 170 |
+
--output out.wav \
|
| 171 |
+
--denoise
|
| 172 |
+
|
| 173 |
+
# 3) Batch processing (one text per line)
|
| 174 |
+
voxcpm --input examples/input.txt --output-dir outs
|
| 175 |
+
# (optional) Batch + cloning
|
| 176 |
+
voxcpm --input examples/input.txt --output-dir outs \
|
| 177 |
+
--prompt-audio path/to/voice.wav \
|
| 178 |
+
--prompt-text "reference transcript" \
|
| 179 |
+
--denoise
|
| 180 |
+
|
| 181 |
+
# 4) Inference parameters (quality/speed)
|
| 182 |
+
voxcpm --text "..." --output out.wav \
|
| 183 |
+
--cfg-value 2.0 --inference-timesteps 10 --normalize
|
| 184 |
+
|
| 185 |
+
# 5) Model loading
|
| 186 |
+
# Prefer local path
|
| 187 |
+
voxcpm --text "..." --output out.wav --model-path /path/to/VoxCPM_model_dir
|
| 188 |
+
# Or from Hugging Face (auto download/cache)
|
| 189 |
+
voxcpm --text "..." --output out.wav \
|
| 190 |
+
--hf-model-id openbmb/VoxCPM-0.5B --cache-dir ~/.cache/huggingface --local-files-only
|
| 191 |
+
|
| 192 |
+
# 6) Denoiser control
|
| 193 |
+
voxcpm --text "..." --output out.wav \
|
| 194 |
+
--no-denoiser --zipenhancer-path iic/speech_zipenhancer_ans_multiloss_16k_base
|
| 195 |
+
|
| 196 |
+
# 7) Help
|
| 197 |
+
voxcpm --help
|
| 198 |
+
python -m voxcpm.cli --help
|
| 199 |
+
```
|
| 200 |
+
|
| 201 |
+
### 4. Start web demo
|
| 202 |
+
|
| 203 |
+
You can start the UI interface by running `python app.py`, which allows you to perform Voice Cloning and Voice Creation.
|
| 204 |
+
|
| 205 |
+
## 🛠️ Fine-tune VoxCPM
|
| 206 |
+
|
| 207 |
+
We provide a training pipeline mirroring the `minicpm-audio` workflow while relying purely on HuggingFace `datasets` for audio-text management.
|
| 208 |
+
|
| 209 |
+
1. **Prepare a manifest (JSONL)**
|
| 210 |
+
|
| 211 |
+
```
|
| 212 |
+
{"audio": "/path/to/audio_0001.wav", "text": "你好,世界。", "dataset_id": 0}
|
| 213 |
+
{"audio": "/path/to/audio_0002.wav", "text": "第二条语音", "dataset_id": 0}
|
| 214 |
+
```
|
| 215 |
+
- `audio`: waveform file path (WAV/FLAC/MP3 supported)
|
| 216 |
+
- `text`: transcription
|
| 217 |
+
- `dataset_id` *(optional)*: integer identifier for multi-dataset sampling statistics
|
| 218 |
+
|
| 219 |
+
2. **Copy & edit the example config**
|
| 220 |
+
`conf/voxcpm/voxcpm_finetune_example.yaml` contains hyper-parameters (pretrained weights, tokenizer, manifests, λ-weights, etc.).
|
| 221 |
+
|
| 222 |
+
3. **Launch training**
|
| 223 |
+
|
| 224 |
+
```bash
|
| 225 |
+
CUDA_VISIBLE_DEVICES=0,1 torchrun --nproc_per_node 2 \
|
| 226 |
+
scripts/train_voxcpm_finetune.py \
|
| 227 |
+
--config_path conf/voxcpm/voxcpm_finetune_example.yaml
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
Features:
|
| 231 |
+
- Distributed + AMP training (`torchrun`).
|
| 232 |
+
- TensorBoard logging (`tensorboard --logdir logs/voxcpm_finetune`).
|
| 233 |
+
- Periodic validation & checkpointing under `checkpoints/`.
|
| 234 |
+
|
| 235 |
+
4. **Key modules**
|
| 236 |
+
- `src/voxcpm/model/voxcpm.py`: unified model providing both inference and training forward。
|
| 237 |
+
- `src/voxcpm/training/`: accelerator, tracker, dataset loader & batch packer utilities。
|
| 238 |
+
- `scripts/train_voxcpm_finetune.py`: end-to-end fine-tune loop。
|
| 239 |
+
|
| 240 |
+
## 👩🍳 A Voice Chef's Guide
|
| 241 |
+
Welcome to the VoxCPM kitchen! Follow this recipe to cook up perfect generated speech. Let’s begin.
|
| 242 |
+
|
| 243 |
+
---
|
| 244 |
+
### 🥚 Step 1: Prepare Your Base Ingredients (Content)
|
| 245 |
+
|
| 246 |
+
First, choose how you’d like to input your text:.
|
| 247 |
+
1. Regular Text (Classic Mode)
|
| 248 |
+
- ✅ Keep "Text Normalization" ON. Type naturally (e.g., "Hello, world! 123"). The system will automatically process numbers, abbreviations, and punctuation using WeTextProcessing library.
|
| 249 |
+
2. Phoneme Input (Native Mode)
|
| 250 |
+
- ❌ Turn "Text Normalization" OFF. Enter phoneme text like {HH AH0 L OW1} (EN) or {ni3}{hao3} (ZH) for precise pronunciation control. In this mode, VoxCPM also supports native understanding of other complex non-normalized text—try it out!
|
| 251 |
+
|
| 252 |
+
---
|
| 253 |
+
### 🍳 Step 2: Choose Your Flavor Profile (Voice Style)
|
| 254 |
+
|
| 255 |
+
This is the secret sauce that gives your audio its unique sound.
|
| 256 |
+
1. Cooking with a Prompt Speech (Following a Famous Recipe)
|
| 257 |
+
- A prompt speech provides the desired acoustic characteristics for VoxCPM. The speaker's timbre, speaking style, and even the background sounds and ambiance will be replicated.
|
| 258 |
+
- For a Clean, Studio-Quality Voice:
|
| 259 |
+
- ✅ Enable "Prompt Speech Enhancement". This acts like a noise filter, removing background hiss and rumble to give you a pure, clean voice clone.
|
| 260 |
+
2. Cooking au Naturel (Letting the Model Improvise)
|
| 261 |
+
- If no reference is provided, VoxCPM becomes a creative chef! It will infer a fitting speaking style based on the text itself, thanks to the text-smartness of its foundation model, MiniCPM-4.
|
| 262 |
+
- Pro Tip: Challenge VoxCPM with any text—poetry, song lyrics, dramatic monologues—it may deliver some interesting results!
|
| 263 |
+
|
| 264 |
+
---
|
| 265 |
+
### 🧂 Step 3: The Final Seasoning (Fine-Tuning Your Results)
|
| 266 |
+
You're ready to serve! But for master chefs who want to tweak the flavor, here are two key spices.
|
| 267 |
+
- CFG Value (How Closely to Follow the Recipe)
|
| 268 |
+
- Default: A great starting point.
|
| 269 |
+
- Voice sounds strained or weird? Lower this value. It tells the model to be more relaxed and improvisational, great for expressive prompts.
|
| 270 |
+
- Need maximum clarity and adherence to the text? Raise it slightly to keep the model on a tighter leash.
|
| 271 |
+
- Inference Timesteps (Simmering Time: Quality vs. Speed)
|
| 272 |
+
- Need a quick snack? Use a lower number. Perfect for fast drafts and experiments.
|
| 273 |
+
- Cooking a gourmet meal? Use a higher number. This lets the model "simmer" longer, refining the audio for superior detail and naturalness.
|
| 274 |
+
|
| 275 |
+
---
|
| 276 |
+
Happy creating! 🎉 Start with the default settings and tweak from there to suit your project. The kitchen is yours!
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
---
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
## 🌟 Community Projects
|
| 283 |
+
|
| 284 |
+
We're excited to see the VoxCPM community growing! Here are some amazing projects and features built by our community:
|
| 285 |
+
|
| 286 |
+
- **[ComfyUI-VoxCPM](https://github.com/wildminder/ComfyUI-VoxCPM)**
|
| 287 |
+
- **[ComfyUI-VoxCPMTTS](https://github.com/1038lab/ComfyUI-VoxCPMTTS)**
|
| 288 |
+
- **[WebUI-VoxCPM](https://github.com/rsxdalv/tts_webui_extension.vox_cpm)**
|
| 289 |
+
- **[PR: Streaming API Support (by AbrahamSanders)](https://github.com/OpenBMB/VoxCPM/pull/26)**
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
*Have you built something cool with VoxCPM? We'd love to feature it here! Please open an issue or pull request to add your project.*
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
## 📊 Performance Highlights
|
| 297 |
+
|
| 298 |
+
VoxCPM achieves competitive results on public zero-shot TTS benchmarks:
|
| 299 |
+
|
| 300 |
+
### Seed-TTS-eval Benchmark
|
| 301 |
+
|
| 302 |
+
| Model | Parameters | Open-Source | test-EN | | test-ZH | | test-Hard | |
|
| 303 |
+
|------|------|------|:------------:|:--:|:------------:|:--:|:-------------:|:--:|
|
| 304 |
+
| | | | WER/%⬇ | SIM/%⬆| CER/%⬇| SIM/%⬆ | CER/%⬇ | SIM/%⬆ |
|
| 305 |
+
| MegaTTS3 | 0.5B | ❌ | 2.79 | 77.1 | 1.52 | 79.0 | - | - |
|
| 306 |
+
| DiTAR | 0.6B | ❌ | 1.69 | 73.5 | 1.02 | 75.3 | - | - |
|
| 307 |
+
| CosyVoice3 | 0.5B | ❌ | 2.02 | 71.8 | 1.16 | 78.0 | 6.08 | 75.8 |
|
| 308 |
+
| CosyVoice3 | 1.5B | ❌ | 2.22 | 72.0 | 1.12 | 78.1 | 5.83 | 75.8 |
|
| 309 |
+
| Seed-TTS | - | ❌ | 2.25 | 76.2 | 1.12 | 79.6 | 7.59 | 77.6 |
|
| 310 |
+
| MiniMax-Speech | - | ❌ | 1.65 | 69.2 | 0.83 | 78.3 | - | - |
|
| 311 |
+
| CosyVoice | 0.3B | ✅ | 4.29 | 60.9 | 3.63 | 72.3 | 11.75 | 70.9 |
|
| 312 |
+
| CosyVoice2 | 0.5B | ✅ | 3.09 | 65.9 | 1.38 | 75.7 | **6.83** | 72.4 |
|
| 313 |
+
| F5-TTS | 0.3B | ✅ | 2.00 | 67.0 | 1.53 | 76.0 | 8.67 | 71.3 |
|
| 314 |
+
| SparkTTS | 0.5B | ✅ | 3.14 | 57.3 | 1.54 | 66.0 | - | - |
|
| 315 |
+
| FireRedTTS | 0.5B | ✅ | 3.82 | 46.0 | 1.51 | 63.5 | 17.45 | 62.1 |
|
| 316 |
+
| FireRedTTS-2 | 1.5B | ✅ | 1.95 | 66.5 | 1.14 | 73.6 | - | - |
|
| 317 |
+
| Qwen2.5-Omni | 7B | ✅ | 2.72 | 63.2 | 1.70 | 75.2 | 7.97 | **74.7** |
|
| 318 |
+
| OpenAudio-s1-mini | 0.5B | ✅ | 1.94 | 55.0 | 1.18 | 68.5 | - | - |
|
| 319 |
+
| IndexTTS2 | 1.5B | ✅ | 2.23 | 70.6 | 1.03 | 76.5 | - | - |
|
| 320 |
+
| VibeVoice | 1.5B | ✅ | 3.04 | 68.9 | 1.16 | 74.4 | - | - |
|
| 321 |
+
| HiggsAudio-v2 | 3B | ✅ | 2.44 | 67.7 | 1.50 | 74.0 | - | - |
|
| 322 |
+
| **VoxCPM** | 0.5B | ✅ | **1.85** | **72.9** | **0.93** | **77.2** | 8.87 | 73.0 |
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
### CV3-eval Benchmark
|
| 326 |
+
|
| 327 |
+
| Model | zh | en | hard-zh | | | hard-en | | |
|
| 328 |
+
|-------|:--:|:--:|:-------:|:--:|:--:|:-------:|:--:|:--:|
|
| 329 |
+
| | CER/%⬇ | WER/%⬇ | CER/%⬇ | SIM/%⬆ | DNSMOS⬆ | WER/%⬇ | SIM/%⬆ | DNSMOS⬆ |
|
| 330 |
+
| F5-TTS | 5.47 | 8.90 | - | - | - | - | - | - |
|
| 331 |
+
| SparkTTS | 5.15 | 11.0 | - | - | - | - | - | - |
|
| 332 |
+
| GPT-SoVits | 7.34 | 12.5 | - | - | - | - | - | - |
|
| 333 |
+
| CosyVoice2 | 4.08 | 6.32 | 12.58 | 72.6 | 3.81 | 11.96 | 66.7 | 3.95 |
|
| 334 |
+
| OpenAudio-s1-mini | 4.00 | 5.54 | 18.1 | 58.2 | 3.77 | 12.4 | 55.7 | 3.89 |
|
| 335 |
+
| IndexTTS2 | 3.58 | 4.45 | 12.8 | 74.6 | 3.65 | - | - | - |
|
| 336 |
+
| HiggsAudio-v2 | 9.54 | 7.89 | 41.0 | 60.2 | 3.39 | 10.3 | 61.8 | 3.68 |
|
| 337 |
+
| CosyVoice3-0.5B | 3.89 | 5.24 | 14.15 | 78.6 | 3.75 | 9.04 | 75.9 | 3.92 |
|
| 338 |
+
| CosyVoice3-1.5B | 3.91 | 4.99 | 9.77 | 78.5 | 3.79 | 10.55 | 76.1 | 3.95 |
|
| 339 |
+
| **VoxCPM** | **3.40** | **4.04** | 12.9 | 66.1 | 3.59 | **7.89** | 64.3 | 3.74 |
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
## ⚠️ Risks and limitations
|
| 353 |
+
- General Model Behavior: While VoxCPM has been trained on a large-scale dataset, it may still produce outputs that are unexpected, biased, or contain artifacts.
|
| 354 |
+
- Potential for Misuse of Voice Cloning: VoxCPM's powerful zero-shot voice cloning capability can generate highly realistic synthetic speech. This technology could be misused for creating convincing deepfakes for purposes of impersonation, fraud, or spreading disinformation. Users of this model must not use it to create content that infringes upon the rights of individuals. It is strictly forbidden to use VoxCPM for any illegal or unethical purposes. We strongly recommend that any publicly shared content generated with this model be clearly marked as AI-generated.
|
| 355 |
+
- Current Technical Limitations: Although generally stable, the model may occasionally exhibit instability, especially with very long or expressive inputs. Furthermore, the current version offers limited direct control over specific speech attributes like emotion or speaking style.
|
| 356 |
+
- Bilingual Model: VoxCPM is trained primarily on Chinese and English data. Performance on other languages is not guaranteed and may result in unpredictable or low-quality audio.
|
| 357 |
+
- This model is released for research and development purposes only. We do not recommend its use in production or commercial applications without rigorous testing and safety evaluations. Please use VoxCPM responsibly.
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
|
| 361 |
+
## 📝TO-DO List
|
| 362 |
+
Please stay tuned for updates!
|
| 363 |
+
- [x] Release the VoxCPM technical report.
|
| 364 |
+
- [ ] Support higher sampling rate (next version).
|
| 365 |
+
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
## 📄 License
|
| 369 |
+
The VoxCPM model weights and code are open-sourced under the [Apache-2.0](LICENSE) license.
|
| 370 |
+
|
| 371 |
+
## 🙏 Acknowledgments
|
| 372 |
+
|
| 373 |
+
We extend our sincere gratitude to the following works and resources for their inspiration and contributions:
|
| 374 |
+
|
| 375 |
+
- [DiTAR](https://arxiv.org/abs/2502.03930) for the diffusion autoregressive backbone used in speech generation
|
| 376 |
+
- [MiniCPM-4](https://github.com/OpenBMB/MiniCPM) for serving as the language model foundation
|
| 377 |
+
- [CosyVoice](https://github.com/FunAudioLLM/CosyVoice) for the implementation of Flow Matching-based LocDiT
|
| 378 |
+
- [DAC](https://github.com/descriptinc/descript-audio-codec) for providing the Audio VAE backbone
|
| 379 |
+
|
| 380 |
+
## Institutions
|
| 381 |
+
|
| 382 |
+
This project is developed by the following institutions:
|
| 383 |
+
- <img src="assets/modelbest_logo.png" width="28px"> [ModelBest](https://modelbest.cn/)
|
| 384 |
+
|
| 385 |
+
- <img src="assets/thuhcsi_logo.png" width="28px"> [THUHCSI](https://github.com/thuhcsi)
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
## ⭐ Star History
|
| 389 |
+
[](https://star-history.com/#OpenBMB/VoxCPM&Date)
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
## 📚 Citation
|
| 393 |
+
|
| 394 |
+
If you find our model helpful, please consider citing our projects 📝 and staring us ⭐️!
|
| 395 |
+
|
| 396 |
+
```bib
|
| 397 |
+
@article{voxcpm2025,
|
| 398 |
+
title = {VoxCPM: Tokenizer-Free TTS for Context-Aware Speech Generation and True-to-Life Voice Cloning},
|
| 399 |
+
author = {Zhou, Yixuan and Zeng, Guoyang and Liu, Xin and Li, Xiang and Yu, Renjie and Wang, Ziyang and Ye, Runchuan and Sun, Weiyue and Gui, Jiancheng and Li, Kehan and Wu, Zhiyong and Liu, Zhiyuan},
|
| 400 |
+
journal = {arXiv preprint arXiv:2509.24650},
|
| 401 |
+
year = {2025},
|
| 402 |
+
}
|
| 403 |
+
```
|
VoxCPM/src/voxcpm.egg-info/SOURCES.txt
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.gitignore
|
| 2 |
+
LICENSE
|
| 3 |
+
README.md
|
| 4 |
+
app.py
|
| 5 |
+
pyproject.toml
|
| 6 |
+
.github/workflows/publish-to-pypi.yml
|
| 7 |
+
assets/modelbest_logo.png
|
| 8 |
+
assets/thuhcsi_logo.png
|
| 9 |
+
assets/voxcpm_logo.png
|
| 10 |
+
assets/voxcpm_model.png
|
| 11 |
+
assets/wechat.png
|
| 12 |
+
examples/example.wav
|
| 13 |
+
src/voxcpm/__init__.py
|
| 14 |
+
src/voxcpm/cli.py
|
| 15 |
+
src/voxcpm/core.py
|
| 16 |
+
src/voxcpm/zipenhancer.py
|
| 17 |
+
src/voxcpm.egg-info/PKG-INFO
|
| 18 |
+
src/voxcpm.egg-info/SOURCES.txt
|
| 19 |
+
src/voxcpm.egg-info/dependency_links.txt
|
| 20 |
+
src/voxcpm.egg-info/entry_points.txt
|
| 21 |
+
src/voxcpm.egg-info/requires.txt
|
| 22 |
+
src/voxcpm.egg-info/top_level.txt
|
| 23 |
+
src/voxcpm/model/__init__.py
|
| 24 |
+
src/voxcpm/model/utils.py
|
| 25 |
+
src/voxcpm/model/voxcpm.py
|
| 26 |
+
src/voxcpm/modules/__init__.py
|
| 27 |
+
src/voxcpm/modules/audiovae/__init__.py
|
| 28 |
+
src/voxcpm/modules/audiovae/audio_vae.py
|
| 29 |
+
src/voxcpm/modules/layers/__init__.py
|
| 30 |
+
src/voxcpm/modules/layers/lora.py
|
| 31 |
+
src/voxcpm/modules/layers/scalar_quantization_layer.py
|
| 32 |
+
src/voxcpm/modules/locdit/__init__.py
|
| 33 |
+
src/voxcpm/modules/locdit/local_dit.py
|
| 34 |
+
src/voxcpm/modules/locdit/unified_cfm.py
|
| 35 |
+
src/voxcpm/modules/locenc/__init__.py
|
| 36 |
+
src/voxcpm/modules/locenc/local_encoder.py
|
| 37 |
+
src/voxcpm/modules/minicpm4/__init__.py
|
| 38 |
+
src/voxcpm/modules/minicpm4/cache.py
|
| 39 |
+
src/voxcpm/modules/minicpm4/config.py
|
| 40 |
+
src/voxcpm/modules/minicpm4/model.py
|
| 41 |
+
src/voxcpm/training/__init__.py
|
| 42 |
+
src/voxcpm/training/accelerator.py
|
| 43 |
+
src/voxcpm/training/config.py
|
| 44 |
+
src/voxcpm/training/data.py
|
| 45 |
+
src/voxcpm/training/packers.py
|
| 46 |
+
src/voxcpm/training/state.py
|
| 47 |
+
src/voxcpm/training/tracker.py
|
| 48 |
+
src/voxcpm/utils/text_normalize.py
|
VoxCPM/src/voxcpm.egg-info/dependency_links.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|