feat(video-pipeline): 重构多阶段生成管线并集成 CosyVoice TTS

- 重写 `phase-images`:改为并发 3 张并行生成,每个 item 完成立即写入 manifest,支持 MJ task ID 恢复
- 重写 `phase-videos`:先恢复已有 task ID 再提交新任务(并发 3),支持中断恢复
- 迁移 TTS 引擎:从 Qwen-TTS HTTP 接口切换为 CosyVoice WebSocket 接口,支持音色/语气参数透传
- 精简账号系统:移除 `styles/` 目录、`taskId` 过滤和 `--id` 正则校验,`references` 改为顶层字段
- 调整 `slugify`:限制中文字符 5 个、其他 10 个,避免文件名过长
- 更新文档:`manifest-schema.md` 中 `narration` 改为完整原文案,`account-creation.md` 新增 TTS 配置项
- 配置更新:默认 TTS 模型切换为 `cosyvoice-v3.5-plus`,新增 `localAudio` 参数
This commit is contained in:
2026-05-01 00:44:18 +08:00
parent 3326f6cb37
commit 7d526d2b60
19 changed files with 888 additions and 411 deletions

View File

@@ -1,7 +1,8 @@
/**
* Command: create-account — 一键创建账号
*
* 创建目录结构 → 复制参考图 → 上传 OSS → 生成 account.json + 风格骨架
* 创建目录结构 → 复制参考图 → 上传 OSS → 生成 account.json
* prompt 文件通过 Agent Q&A 流程生成(见 account-creation.md
*/
const fs = require('fs')
@@ -9,10 +10,9 @@ const path = require('path')
const { ensureDir, log, ACCOUNTS_DIR } = require('./pipeline-utils')
async function createAccount(args) {
const { id, name, desc, format, imageModel, videoModel, references } = args
const { id, name, desc, format, imageModel, videoModel, references, ttsVoice, ttsInstruction } = args
if (!id) { console.error('错误: 必须指定 --id <账号ID>'); process.exit(1) }
if (!/^[a-z0-9_-]+$/.test(id)) { console.error('错误: id 只允许小写字母/数字/短横线/下划线'); process.exit(1) }
if (!name) { console.error('错误: 必须指定 --name <账号名>'); process.exit(1) }
const accountDir = path.join(ACCOUNTS_DIR, id)
@@ -21,7 +21,6 @@ async function createAccount(args) {
ensureDir(accountDir)
ensureDir(path.join(accountDir, 'prompts'))
ensureDir(path.join(accountDir, 'references'))
ensureDir(path.join(accountDir, 'styles'))
// 复制参考图到 references/ 并上传 OSS
const refs = (references || '').split(',').filter(Boolean)
@@ -47,7 +46,6 @@ async function createAccount(args) {
}
// 生成 account.json
const styleName = args.style || id
const accountConfig = {
id,
name,
@@ -56,9 +54,12 @@ async function createAccount(args) {
imageModel: imageModel || 'gemini',
videoModel: videoModel || '',
batchSize: 30,
ttsVoice: ttsVoice || '',
ttsInstruction: ttsInstruction || '',
storyboardPrompt: 'prompts/分镜.md',
imageStylePrompt: 'prompts/图片提示词.md',
videoStylePrompt: 'prompts/视频提示词.md',
references: uploadedRefs,
capcut: {
effects: [],
filter: '',
@@ -72,65 +73,15 @@ async function createAccount(args) {
},
}
if (uploadedRefs.length > 0) {
accountConfig.styles = {
[styleName]: { references: uploadedRefs },
}
}
const accountPath = path.join(accountDir, 'account.json')
fs.writeFileSync(accountPath, JSON.stringify(accountConfig, null, 2), 'utf-8')
// 生成默认风格骨架
const stylePath = path.join(accountDir, 'styles', `${styleName}.md`)
const styleContent = [
`# ${styleName}`,
'',
`${desc || name} 的视觉风格。`,
'',
'---',
'',
'## 图片提示词',
'',
'### 核心视觉要素',
'',
'(待填充:描述关键视觉元素)',
'',
'### 色调方案',
'',
'(待填充)',
'',
'### 图片 Prompt 模板',
'',
'(待填充)',
'',
'### 图片禁止项',
'',
'- 文字水印',
'- 字幕覆盖',
'',
'---',
'',
'## 视频提示词',
'',
'### 运镜规则',
'',
'(待填充)',
'',
'### 视频 Prompt 模板',
'',
'(待填充)',
'',
].join('\n')
fs.writeFileSync(stylePath, styleContent, 'utf-8')
console.log(`\n账号已创建: ${accountDir}`)
console.log(` ID: ${id}`)
console.log(` 名称: ${name}`)
console.log(` 模型: ${accountConfig.imageModel} + ${accountConfig.videoModel || '(未指定)'}`)
console.log(` 参考图: ${uploadedRefs.length} 张(${uploadedRefs.filter(r => r.url).length} 已上传)`)
console.log(` 风格: ${styleName}`)
console.log(`\n下一步: 编辑 ${stylePath} 完善提示词策略\n`)
console.log(`\n下一步: 通过 Agent Q&A 流程生成 prompts/*.md或手动创建\n`)
return accountPath
}