Fish Speech V1.5 是一款领先的多语言文本转语音(TTS)模型,其训练基于超过100万小时的音频数据。本仓库包含经适配并验证可在华为昇腾NPU上进行推理的模型。
| 属性 | 值 |
|---|---|
| 模型 | Fish Speech V1.5 |
| 架构 | DualAR Transformer(GPT风格 + 快速码本解码器) |
| 参数规模 | 637.9M |
| 精度 | BF16 |
| 基础模型 | fishaudio/fish-speech-1.5 |
| 支持语言 | zh, en, ja, de, fr, es, ko, ar, nl, ru, it, pl, pt |
| 声码器 | Firefly-GAN VQ-FSQ-8x1024-21Hz |
| 许可证 | CC-BY-NC-SA-4.0 |
Fish Speech V1.5模型采用双自回归(DualAR) 架构:
推理流程:文本 → 分词器 → DualAR Transformer → 矢量量化码(VQ Codes)→ Firefly-GAN声码器 → 音频
| 组件 | 规格 |
|---|---|
| NPU | 昇腾910B2 / 910B / 910A |
| CANN | 8.5.1或更高版本 |
| 驱动 | 昇腾HDK 24.1+ |
| torch_npu | 2.9.0+ |
| PyTorch | 2.9.0+ |
| 内存 | ≥ 8 GB NPU内存 |
| 存储 | ≥ 3 GB可用磁盘空间 |
NPU: Ascend 910B2 (9362) x2
CANN: 8.5.1
PyTorch: 2.9.0
torch_npu: 2.9.0.post1
Python: 3.11
OS: Linux (aarch64)# Install dependencies
pip install torch torch_npu
pip install modelscope loguru tiktoken soundfile numpy
pip install dac # For vocoder support
# Set environment variables
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True# Download the model
pip install modelscope
modelscope download --model fishaudio/fish-speech-1.5 --local_dir ./fish-speech-1.5
# Clone the fish-speech repo for tokenizer support
git clone --depth 1 https://github.com/fishaudio/fish-speech.git /tmp/fish-speech# Basic TTS inference
python inference.py \
--model-path ./fish-speech-1.5 \
--text "Hello world, this is a test of Fish Speech on Ascend NPU." \
--output output.wav
# Chinese text
python inference.py \
--model-path ./fish-speech-1.5 \
--text "你好,世界!这是Fish Speech在昇腾NPU上的测试。" \
--output output_cn.wav \
--temperature 0.7 \
--top-p 0.9
# With custom sampling parameters
python inference.py \
--model-path ./fish-speech-1.5 \
--text "Your text here." \
--output output.wav \
--temperature 0.8 \
--top-p 0.8 \
--top-k 40 \
--max-new-tokens 256python evaluation/eval_precision.py \
--model-path ./fish-speech-1.5 \
--output-dir ./evaluationpython evaluation/eval_performance.py \
--model-path ./fish-speech-1.5 \
--num-decode-tokens 100 \
--decode-runs 5 \
--output-dir ./evaluation| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
--model-path | str | ./fish-speech-1.5 | 模型目录路径 |
--text | str | 必填 | TTS输入文本 |
--output | str | output.wav | 输出音频文件路径 |
--max-new-tokens | int | 512 | 最大生成token数量 |
--temperature | float | 0.7 | 采样温度(0-2) |
--top-p | float | 0.7 | Top-p(核)采样 |
--top-k | int | 30 | Top-k采样 |
--device-id | int | 0 | NPU设备ID |
--skip-vocoder | 标志 | False | 跳过音频生成 |
--codes-output | str | None | 将VQ码保存为.npy文件 |
以下优化适用于昇腾NPU推理:
PYTORCH_NPU_ALLOC_CONF=expandable_segments:True:启用动态内存段扩展,减少内存碎片@torch.inference_mode())进行算子融合torch.npu.synchronize()确保计时准确| 测试项目 | 结果 | 阈值 |
|---|---|---|
| 权重加载(BF16与FP32对比) | < 1% 相对误差 | 1% |
| CPU与NPU编码重叠度 | ~95%+ | - |
| 输出编码范围 | [0, 1023] | 有效码本范围 |
精度状态:✅ 通过(误差 < 1%)
性能在昇腾910B2上以BF16精度测量:
| 指标 | 数值 |
|---|---|
| 模型加载时间 | ~8秒 |
| 预填充延迟(提示=50个token) | ~200毫秒 |
| 解码吞吐量 | ~30-50 token/秒 |
| NPU内存(峰值) | ~4-6 GB |
| 首token延迟 | ~300毫秒 |
注:性能因提示长度、生成序列长度和采样参数而异。
fish-speech-1.5/
├── config.json # Model configuration
├── model.pth # DualAR Transformer checkpoint
├── firefly-gan-vq-fsq-8x1024-21hz-generator.pth # Vocoder checkpoint
├── tokenizer.tiktoken # Tokenizer
├── special_tokens.json # Special tokens
├── inference.py # NPU inference script
├── README.md # This document
└── evaluation/
├── eval_precision.py # Precision evaluation script
├── eval_performance.py # Performance benchmark script
├── precision_results.json # Precision test results
└── performance_results.json # Performance benchmark resultsdac 包。若该包不可用,脚本将保存原始 VQ 码。@misc{fish-speech-v1.4,
title={Fish-Speech: Leveraging Large Language Models for Advanced Multilingual Text-to-Speech Synthesis},
author={Shijia Liao and Yuxuan Wang and Tianyu Li and Yifan Cheng and Ruoyi Zhang and Rongzhi Zhou and Yijin Xing},
year={2024},
eprint={2411.01156},
archivePrefix={arXiv},
primaryClass={cs.SD},
url={https://arxiv.org/abs/2411.01156},
}本模型采用 CC-BY-NC-SA-4.0 许可协议。详情请参见原始 Fish Speech 仓库。