将视频制作工作流拆分为独立子步骤:分镜 → 图片提示词 → 生图 → 视频提示词 → 生视频 → 成片,每步由子Agent独立执行。引入prompts/目录统一管理提示词模板(分镜.md、图片提示词.md、视频提示词.md),通过account.json的storyboardPrompt/imageStylePrompt/videoStylePrompt字段引用。 变更内容: - 新增confirmed机制和pipeline.js confirm命令,生图后必须人工确认才能继续 - manifest schema改用shotDesc/narration/duration/directorRef替代旧字段 - 文件命名规则从keyword改为slug(从shotDesc/narration派生) - 删除旧的storyboard-rules.md和prompt-rules.md - pipeline.js脚本拆分为lib/目录下的独立模块(cmd-init/cmd-confirm/cmd-validate/phase-*) - 新增cmd-create-account支持一键创建带prompts目录的账号 - capcut_assemble支持narration字段替代text作为字幕源 - 新增.gitclaude/settings.json权限配置
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
/**
|
||
* Phase: tts — 语音合成
|
||
*
|
||
* 使用通义千问 TTS 生成旁白音频
|
||
*/
|
||
|
||
const path = require('path')
|
||
const { saveManifest, ensureDir, log, getManifestDir } = require('./pipeline-utils')
|
||
|
||
async function phaseTts(manifest, manifestPath) {
|
||
const dir = getManifestDir(manifestPath)
|
||
const audioDir = path.join(dir, 'audio')
|
||
ensureDir(audioDir)
|
||
|
||
const { synthesize } = require('../qwen-tts')
|
||
|
||
const items = manifest.items.filter(it =>
|
||
it.status === 'done' && (it.narration || it.text) && !it.audio
|
||
)
|
||
if (items.length === 0) { log('tts', '无待处理 item,跳过'); return }
|
||
|
||
log('tts', `共 ${items.length} 段`)
|
||
|
||
for (let i = 0; i < items.length; i++) {
|
||
const item = items[i]
|
||
const idx = i + 1
|
||
try {
|
||
const { filePath, duration } = await synthesize(item.narration || item.text, {
|
||
outputDir: audioDir,
|
||
id: item.id || idx,
|
||
})
|
||
item.audio = path.relative(dir, filePath).replace(/\\/g, '/')
|
||
item.audioDuration = Math.round(duration * 1000) / 1000
|
||
log('tts', `[${idx}/${items.length}] ${duration.toFixed(1)}s: ${(item.narration || item.text).substring(0, 30)}...`)
|
||
} catch (err) {
|
||
item.status = 'failed'
|
||
item.error = `TTS失败: ${err.message}`
|
||
log('tts', `[${idx}/${items.length}] 失败: ${err.message}`)
|
||
}
|
||
saveManifest(manifestPath, manifest)
|
||
}
|
||
}
|
||
|
||
module.exports = { phaseTts }
|