feat(tts): 科普视频管线支持 IndexTTS-2.5 声音克隆配音(双引擎 + 风格控制 + 操作手册) - #1104
Merged
Conversation
- tts.py 双引擎改造:edge(默认,digest/CLI/manifest 字节级不变)+ indextts(HTTP 客户端逐句克隆合成); - 新增 tts_server.py:运行于 index-tts checkout 环境的 FastAPI 推理服务(lifespan 模型常驻、串行锁、v2/v2.5 双版本、NaN 后置检测、soundfile→lameenc MP3 编码链); - 新增 prepare_ref.py:长录音裁剪/归一化为 5–15s 干净 16-bit 单声道参考样本; - 风格预设(中性/轻快/自信/正能量)映射 8 维情感向量 + emo_alpha + duration_factor,双端校验(非负有限值 + 有效和 ≤0.8); - 缓存摘要覆盖 engine_tag/ref_sha1/style/vec/alpha/df/lang,4xx 不可重试、5xx 指数退避重试; 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
- VOICE-CLONING.md 九节操作手册:部署(磁盘预算/断点续传/下载假死处置)/参考样本录制要求/风格预设与调参/逐集使用/缓存幂等语义/MPS 排障/bilibili 许可边界/备选方案对比 + IEEE 引用; - voices/README.md:样本目录约定与隐私提醒;根 .gitignore 目录级忽略个人声纹(仅白名单 README); - media/pipeline/README.md:脚本表补 tts_server/prepare_ref、§五 引擎可选说明、§八 许可补充; - knowledge-map:管线条目追加声音克隆手册链接; 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
- CONCURRENCY_INDEXTTS 2→1:服务端为串行推理锁,>1 的并发请求在锁后排队,排队时长计入客户端 HTTP 超时,长句场景连续超时(实测 p0-08/p0-12/p0-12b 三次命中); - HTTP_TIMEOUT 300→600:覆盖 MPS fp32 长句(33 字句实测可达 5 分钟); - 手册 §五 同步并发语义说明; 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
- 渲染命令补 cd video &&(render 脚本定义在 video/package.json,照抄原命令会报 Missing script) - 故障排查表 HTTP_TIMEOUT 300s→600s 并同步 §五 超时描述(对齐 commit b70afc3 与 tts.py:41) - 移除 m4a 可转换声明:libsndfile 1.2.2 无 MP4 容器支持,改为注明先经 ffmpeg 转 wav 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
- VOICE-CLONING.md §4.2 与 tts.py 顶部注释:情感向量约束实为有效和(Σ分量×emo-alpha)≤0.8, 而非分量总和 ≤0.8(positive 预设总和 0.95 即为反例),补 happy:1.0@alpha=0.6 放行示例; - tts.py parse_emo_vector:NaN/Inf 拦截改为显式 math.isfinite(与服务端写法对齐, 拒绝/放行语义经 10 用例回归验证不变); - README.md 公共脚本表:prepare_ref.py 无工程薄包装,改为仓库根全路径调用指引。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
…/tts-voice-clone-index # Conflicts: # .gitignore # docs/.agents/knowledge-map.md
- --server 尾部斜杠原仅 synthesize 拼接处 rstrip、health 检查拼出 //health 致 404 误报「服务不可用」;改为解析参数后统一归一化一处收口; - parse_emo_vector 原对重复情感键静默 last-wins 丢弃首个权重;改为显式报「情感键重复」,与未知键/负值/NaN 同级校验。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
科普视频管线(
media/pipeline/)新增用自己的声音配音能力:通过本地部署 IndexTTS-2.5 零样本克隆用户音色,并支持轻快 / 自信 / 正能量等风格控制。edge-tts 无法克隆声音(仅微软预置音色),故保留为默认引擎(行为字节级不变),新增--engine indextts声音克隆模式。调研结论(多方案对比)
--indextts-version 2一键回退架构
管线轻依赖与重型推理环境完全解耦:
tts.py --engine indextts(stdlib urllib 客户端,零新增依赖)→ HTTP → 本地tts_server.py(FastAPI,运行于仓库外~/tools/index-tts的 uv 环境内,模型常驻 MPS 串行推理)→ MP3。下游契约零改动:输出仍为{id}.mp3 + manifest.json,Remotion 时间轴/字幕/抽帧 QA 自动适配。改动清单
media/pipeline/scripts/tts.py— 双引擎改造;edge 路径 digest 公式/CLI/manifest 序列化字节级不变;indextts 路径含缓存摘要(engine_tag/ref_sha1/style/vec/alpha/df/lang)、4xx 不可重试、5xx 指数退避media/pipeline/scripts/tts_server.py— 新增;lifespan 模型常驻、串行推理锁、NaN 后置检测、soundfile→lameenc MP3 编码链、v2/v2.5 双版本media/pipeline/scripts/prepare_ref.py— 新增;长录音裁剪/峰值归一化为 5–15s 干净 16-bit 单声道 WAVmedia/pipeline/VOICE-CLONING.md— 新增九节操作手册(部署/录音/风格调参/排障/许可/备选对比 + IEEE 引用)media/pipeline/voices/— 样本目录约定 + 隐私规范;根.gitignore目录级忽略个人声纹media/pipeline/README.md/docs/.agents/knowledge-map.md— 脚本表、引擎说明、许可、索引同步风格预设(8 维情感向量,双端校验有效和 ≤0.8)
E2E 验证(本机 M4/24GB 实测)
/health→{version: 2.5, device: mps, dtype: fp32, encoder: soundfile};单句冒烟 MP3 时长与X-Duration-Sec头一致(±0.05s)me-1.mp3264s → prepare_ref 裁剪 14s)克隆合成:neutral/lively/confident/positive 四风格各出样本,时长梯度符合风格特征(lively 3.41s < positive 3.51s < neutral 3.78s){id, scene, text, durationSec}、顺序、序列化格式与 edge 引擎完全一致--list-styles、互斥校验、缺 ref 报错、服务未启动友好指引、NaN/Inf/有效和拦截--device auto崩溃、向量校验语义(改为有效和 Σvec×alpha≤0.8,对齐 v2.5 源码 alpha 缩放行为)、dtype 误报、摘要精度、尾斜杠 URL、422 详情解析、负数 start、gitignore 漏网格式、knowledge-map 措辞回退回归定义:edge 模式不要求全新合成 mp3 字节一致(网络合成非确定性);契约 = CLI 兼容 + digest 不变 + 缓存命中时 manifest 字节一致 + 形状不变。
许可
IndexTTS-2.5 按 bilibili Model Use License 发布(个人/研究可用,商用联系 indexspeech@bilibili.com);个人声纹样本已被 gitignore 隔绝入库。
🤖 Generated with Claude Code, CodeX, Gemini