🎬 Fun-CineForge: 阿里通义实验室开源的影视级多模态配音大模型,支持零样本电影配音。
基于华为昇腾 Ascend 910 NPU 的 FunAudioLLM/Fun-CineForge 适配,已通过精度/性能/稳定性全部评测。
#NPU
Fun-CineForge 是阿里通义实验室开源的影视级多模态配音大模型,支持零样本(Zero-Shot)电影配音。模型基于 Qwen2-0.5B + CosyVoice 3 架构,融合视觉、文本、音频和时间四种模态,实现高精度的唇音同步和情感表达。
本仓库提供 Fun-CineForge 在华为昇腾 Ascend 910 NPU 上的完整适配方案。
输入: 无声视频片段 + 配音文本 + 参考音频 + 时间信息
↓
多模态编码 → Qwen2-0.5B LLM (NPU) → 语音Token生成
↓
CosyVoice Flow Matching (NPU) → 梅尔频谱生成
↓
HiFT-Causal Vocoder (NPU) → 音频波形输出| 组件 | 模型 | NPU适配 |
|---|---|---|
| 语言模型 | Qwen2-0.5B-CosyVoice | ✓ torch_npu |
| 说话人嵌入 | CAM++ | ✓ ONNX Runtime |
| 面部特征 | IR-101 Face Recognition | ✓ ONNX Runtime |
| 语音活动检测 | FSMN-VAD | ✓ PyTorch |
| 声码器 | HiFT-Causal | ✓ torch_npu |
pip install torch==2.9.0 torch_npu==2.9.0
pip install transformers>=4.40 soundfile librosa numpy
pip install modelscope # 模型下载modelscope download --model FunAudioLLM/Fun-CineForge --local_dir ./Fun-CineForge# 文本配音
python inference.py --text "欢迎使用Fun-CineForge配音模型" --output output.wav
# 带参考音频的配音
python inference.py \
--text "这是一段配音文本" \
--ref-audio reference.wav \
--output dubbed.wav
# 指定NPU设备
python inference.py --text "测试文本" --device npu:0from inference_pipeline import FunCineForgePipeline
pipeline = FunCineForgePipeline(device="npu:0")
result = pipeline.dub_file(
text="配音文本内容",
ref_audio_path="speaker_reference.wav",
video_path="silent_video.mp4",
output_path="dubbed_output.wav",
scene_clue="室内对话场景",
speaker_gender="female",
)# 完整评测 (精度 + 性能 + 稳定性)
python evaluation.py
# 快速评测
python evaluation.py --quick
# 生成评测报告
python evaluation.py --report evaluation_report.json评测环境: Ascend 910 (Ascend910_9362) × 2, torch 2.9.0 + torch_npu 2.9.0.post1
| 测试用例 | 文本长度 | 最大绝对差 | 平均绝对差 | 相对误差 | 生成一致性 | 结果 |
|---|---|---|---|---|---|---|
| 短文本 | 13字 | 0.371 | 0.012 | 0.345% | ✓ | PASS |
| 中等文本 | 32字 | 0.609 | 0.008 | 0.233% | ✓ | PASS |
| 长文本 | 110字 | 0.569 | 0.006 | 0.193% | ✓ | PASS |
平均相对误差: 0.257% (< 1% 阈值)
结论: NPU 与 CPU 推理精度误差 < 1%,全部测试通过。
| 指标 | 数值 |
|---|---|
| LLM 前向耗时 | 26.49ms (平均) |
| Token 生成速度 | ~40 tok/s (自回归) |
| 估算实时率 (RTF) | 0.013x |
| NPU 相对 CPU 加速 | ~2.2x (前向) / ~22x (整体) |
结论: RTF = 0.013x << 1.0,完全满足实时配音需求。
| 指标 | 结果 |
|---|---|
| 确定性生成 (5次) | ✓ 完全一致 |
| 确定性耗时 | 1.595s ± 0.012s |
| 随机生成长度 | 81 ± 0 tokens (0.00% 标准差) |
| 随机生成耗时 | 1.843s ± 0.038s |
结论: 模型推理稳定性优秀,多次推理输出完全一致。
Fun-CineForge/
├── inference.py # 主推理脚本 (NPU适配)
├── inference_pipeline.py # 完整推理流水线
├── evaluation.py # 精度与性能评测脚本
├── README.md # 本文档
├── Qwen2-0.5B-CosyVoice-BlankEN/ # Qwen2 基础模型
├── funcineforge_zh_en/ # Fun-CineForge 模型配置
│ ├── llm/ # LLM 配置
│ ├── flow/ # Flow Matching 配置
│ └── vocoder/ # HiFT-Causal 声码器
├── speech_campplus/ # 说话人嵌入模型
└── speech_fsmn_vad/ # 语音活动检测模型.to("npu:0") 迁移至昇腾 NPUtorch_npu 加速矩阵乘法和注意力计算PYTORCH_NPU_ALLOC_CONF=expandable_segments:True# NPU 亲和性配置
export CPU_AFFINITY_CONF=0-15
# 内存分配器
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
# 算子调优
export ASCEND_LAUNCH_BLOCKING=0@misc{liu2026funcineforgeunifieddatasettoolkit,
title={FunCineForge: A Unified Dataset Toolkit and Model for
Zero-Shot Movie Dubbing in Diverse Cinematic Scenes},
author={Jiaxuan Liu and Yang Xiang and Han Zhao and
Xiangang Li and Zhenhua Ling},
year={2026},
eprint={2601.14777},
archivePrefix={arXiv},
primaryClass={cs.CV},
}本项目基于 Apache 2.0 License 开源。模型权重遵循原始 Fun-CineForge 许可协议。