--- license: agpl-3.0 language: - en - zh base_model: - openbmb/VoxCPM-0.5B pipeline_tag: text-to-speech tags: - rknn - rkllm - text-to-speech - speech - speech generation - voice cloning --- # VoxCPM-0.5B-RKNN2 ### (English README see below) VoxCPM 是一种创新的无分词器文本转语音(TTS)系统,重新定义了语音合成的真实感。通过在连续空间中建模语音,它克服了离散标记化的局限,并实现了两项核心能力:上下文感知的语音生成和逼真的零样本语音克隆。 不同于将语音转换为离散标记的主流方法,VoxCPM 采用端到端的扩散自回归架构,直接从文本生成连续的语音表示。它基于 MiniCPM-4 主干构建,通过分层语言建模和 FSQ 约束实现了隐式的语义-声学解耦,极大地提升了表现力和生成稳定性。 ![模型架构](model_structure.jpg) - 推理速度(RKNN2):RK3588上RTF约4.5(生成10s音频需要推理45s) - 大致内存占用(RKNN2):约3.3GB ## 使用方法 1. 克隆项目到本地 2. 安装依赖 ```bash pip install numpy scipy soundfile tqdm transformers sentencepiece ztu-somemodelruntime-ez-rknn-async ``` 3. 运行 ```bash python onnx_infer-rknn2.py --onnx-dir . --tokenizer-dir . --base-hf-dir . --residual-hf-dir . --text "哇, 这个模型居然在RK3588这个辣鸡SoC上也能完美运行!" --prompt-audio basic_ref_zh.wav --prompt-text "对,这就是我,万人敬仰的太乙真人。" --output rknn_output.wav --cfg-value 2.0 --inference-timesteps 10 --seed 1234 ``` 可选参数: - `--text`: 要生成的文本 - `--prompt-audio`: 参考音频路径(用于语音克隆) - `--prompt-text`: 参考音频对应的文本(使用参考音频时必填) - `--cfg-value`: CFG引导强度,默认2.0 - `--inference-timesteps`: 扩散步数,默认10 - `--seed`: 随机种子 - `--output`: 输出音频路径 ## 运行效果 ```log > python onnx_infer-rknn2.py --onnx-dir . --tokenizer-dir . --base-hf-dir . --residual-hf-dir . --text "哇, 这个模型居然在RK3588这个辣鸡SoC上也能完美运行!" --prompt-audio basic_ref_zh.wav --prompt-text "对,这就是我,万人敬仰的太乙真人。" --output rknn_output.wav --cfg-value 2.0 --inference-timesteps 10 --seed 1234 I rkllm: rkllm-runtime version: 1.2.3, rknpu driver version: 0.9.8, platform: RK3588 I rkllm: loading rkllm model from ./base_lm.rkllm I rkllm: rkllm-toolkit version: 1.2.3, max_context_limit: 4096, npu_core_num: 1, target_platform: RK3588, model_dtype: FP16 I rkllm: Enabled cpus: [4, 5, 6, 7] I rkllm: Enabled cpus num: 4 I rkllm: rkllm-runtime version: 1.2.3, rknpu driver version: 0.9.8, platform: RK3588 I rkllm: loading rkllm model from ./residual_lm.rkllm I rkllm: rkllm-toolkit version: 1.2.2, max_context_limit: 4096, npu_core_num: 3, target_platform: RK3588, model_dtype: FP16 I rkllm: Enabled cpus: [4, 5, 6, 7] I rkllm: Enabled cpus num: 4 [time] vae_encode_0: 1502.91 ms [time] vae_encode_38400: 1443.79 ms [time] vae_encode_76800: 1418.36 ms [time] locenc_0: 820.25 ms [time] locenc_64: 814.78 ms [time] locenc_128: 815.60 ms [time] base_lm initial: 549.21 ms [time] fsq_init_0: 5.34 ms [time] fsq_init_64: 3.95 ms [time] fsq_init_128: 4.17 ms [time] residual_lm initial: 131.22 ms gen_loop: 0%| | 0/2000 [00:00 python onnx_infer-rknn2.py --onnx-dir . --tokenizer-dir . --base-hf-dir . --residual-hf-dir . --text "哇, 这个模型居然在RK3588这个辣鸡SoC上也能完美运行!" --prompt-audio basic_ref_zh.wav --prompt-text "对,这就是我,万人敬仰的太乙真人。" --output rknn_output.wav --cfg-value 2.0 --inference-timesteps 10 --seed 1234 I rkllm: rkllm-runtime version: 1.2.3, rknpu driver version: 0.9.8, platform: RK3588 I rkllm: loading rkllm model from ./base_lm.rkllm I rkllm: rkllm-toolkit version: 1.2.3, max_context_limit: 4096, npu_core_num: 1, target_platform: RK3588, model_dtype: FP16 I rkllm: Enabled cpus: [4, 5, 6, 7] I rkllm: Enabled cpus num: 4 I rkllm: rkllm-runtime version: 1.2.3, rknpu driver version: 0.9.8, platform: RK3588 I rkllm: loading rkllm model from ./residual_lm.rkllm I rkllm: rkllm-toolkit version: 1.2.2, max_context_limit: 4096, npu_core_num: 3, target_platform: RK3588, model_dtype: FP16 I rkllm: Enabled cpus: [4, 5, 6, 7] I rkllm: Enabled cpus num: 4 [time] vae_encode_0: 1502.91 ms [time] vae_encode_38400: 1443.79 ms [time] vae_encode_76800: 1418.36 ms [time] locenc_0: 820.25 ms [time] locenc_64: 814.78 ms [time] locenc_128: 815.60 ms [time] base_lm initial: 549.21 ms [time] fsq_init_0: 5.34 ms [time] fsq_init_64: 3.95 ms [time] fsq_init_128: 4.17 ms [time] residual_lm initial: 131.22 ms gen_loop: 0%| | 0/2000 [00:00