--- license: apache-2.0 language: - zh tags: - text-to-speech - tts - chinese - axera - axmodel - onnx pipeline_tag: text-to-speech --- # Inflect-Micro-v2-zh 从零训练的中文 TTS:基于 [Inflect-Micro-v2](https://huggingface.co/owensong/Inflect-Micro-v2) 架构(Apache-2.0)+ [NVIDIA BigVGAN](https://github.com/NVIDIA/BigVGAN) 声码器(MIT)。 声学模型 6.7M 参数(text→100-band mel),可在 **AX650 系列 NPU** 上实时部署 (CPU + NPU 混合架构,RTF 0.15-0.19)。 ## 示例音频(AX650 板上 C++ SDK 实跑) 以下音频由交付的 **C++ SDK** 在 AX650 板端到端生成(acoustic ONNX 于 CPU + BigVGAN axmodel 于 NPU int8,女声 v2:mel-GAN + length_scale=1.0 + noise=0),可直接试听: 女声 · 日常口语:“今天中午我想吃一碗牛肉面。” 女声 · 新闻播报:“中国人民银行决定下调存款准备金率。” 男声 · 日常口语:“请问最近的医院在哪里。” 女声 · 送气音示例:“天气允许的话” ## 长文本示例(Python SDK 自动分句,AX650 板上实跑,约 22s) 女声 · 长文本:央行降准新闻 + 北京简介 男声 · 长文本:人工智能话题节目开场 > 长文本由 Python SDK `infer_board.py` 自动分句(≤250 tokens/句)后拼接,句间 0.2s 停顿。 ## 文件说明 ``` models/ ├── acoustic_female.onnx (+ .data) # 女声 文本→mel(CPU fp32,ls=0.7) ├── acoustic_male.onnx (+ .data) # 男声 文本→mel(CPU fp32,ls=0.85) ├── bigvgan_base.onnx (+ .data) # 声码器 mel→wav(CPU fp32,动态帧) ├── bigvgan_base.axmodel # 声码器 mel→wav(AX650 NPU int8) └── model_meta.json # 模型规格元数据 checkpoints/ # 训练权重(PyTorch) ├── base300.pt # 基础模型(AiShell-3,20 说话人) ├── female_gan.pt # 女声(CosyVoice 音色 + GAN) └── male_gan.pt # 男声(SSB0609 音色 + GAN) python/ # Python 推理 SDK reports/ # 验证报告(可懂度/性能/量化) ``` ## 快速开始(Python,CPU) ```bash pip install onnxruntime numpy soundfile pypinyin python python/infer_onnx.py \ --text "你好世界,今天天气真不错,适合出去散步。" \ --acoustic models/acoustic_female.onnx \ --vocoder models/bigvgan_base.onnx \ --output out.wav ``` ## 快速开始(AX650 板,CPU+NPU 混合) 板上安装 `onnxruntime`、`pypinyin` 和 `axengine`(AXERA 提供): ```bash python python/infer_board.py \ --text "人工智能技术正在改变我们的生活方式。" \ --acoustic models/acoustic_female.onnx \ --vocoder models/bigvgan_base.axmodel \ --output out.wav ``` `infer_board.py` 自动完成:文本分句 → 声学模型(CPU)→ mel 后处理 (静音门限 + 句尾拉伸)→ 声码器(NPU)分块拼接。 ## 性能(AX650N 实测) | 组件 | 耗时 | 说明 | |---|---|---| | acoustic(CPU fp32) | 0.30s/句 | 静态 max_mel=1024(单句 ≤10.9s) | | vocoder(NPU int8) | 0.30s/块 | 512 mel 帧 = 5.46s 音频 | | 整链路 RTF | 0.15-0.19 | 约 6x 实时 | ## 可懂度(SenseVoice,8 句测试) | 音色 | CER | |---|---| | 女声(CPU 全 fp32) | 0.075 | | 男声(CPU 全 fp32) | 0.108 | ## 说明 - 声学模型必须 CPU fp32:VITS 的 flow/duration 对 NPU 8/16-bit 量化系统性敏感 (int8/U16/BRecQ 全部验证失败);声码器 NPU int8 可用 - 长文本自动分句(≤250 tokens/句)+ 声码器分块拼接(重叠交叉淡化) - 训练流程与复现脚本见 [GitHub 仓库](https://github.com/ml-inory/Inflect-Micro-v2-zh) ## 致谢 - [owensong/Inflect-Micro-v2](https://huggingface.co/owensong/Inflect-Micro-v2)(架构,Apache-2.0) - [NVIDIA BigVGAN](https://github.com/NVIDIA/BigVGAN)(声码器,MIT) - [FunAudioLLM/CosyVoice](https://github.com/FunAudioLLM/CosyVoice)(数据生成,Apache-2.0) - [OpenSLR AISHELL-3](https://www.openslr.org/resources/93/)(中文语料) - AXERA Pulsar2(AX 编译工具链) 完整第三方声明见 GitHub 仓库 `THIRD_PARTY_NOTICES.md`。 ## License [Apache-2.0](https://github.com/ml-inory/Inflect-Micro-v2-zh/blob/main/LICENSE) (与原版 Inflect-Micro-v2 一致)