feat(tts): 添加语音剪气口功能以去除首尾静音

- 集成 ffmpeg 实现自动检测并切除音频首尾静音段
- 新增 trimSilence 和 getAudioDuration 辅助函数
- 裁剪后若时长缩短则替换原音频文件,使片段时长更贴近真实语长
- 更新剪映草稿路径和 capcut-mate 目录配置
This commit is contained in:
2026-05-07 00:42:47 +08:00
parent ce54a65abb
commit ca13cf8757
2 changed files with 6 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{ {
"jianyingDraftPath": "/Users/lc/Movies/JianyingPro/User Data/Projects/com.lveditor.draft", "jianyingDraftPath": "C:/Users/45070/AppData/Local/JianyingPro/User Data/Projects/com.lveditor.draft",
"capcutMateDir": "C:/Users/45070/capcut-mate", "capcutMateDir": "/Users/lc/capcut-mate",
"capcutMateApiBase": "http://capcut.muyetools.cn/openapi/capcut-mate/v1", "capcutMateApiBase": "http://capcut.muyetools.cn/openapi/capcut-mate/v1",
"imgbbApiKey": "deprecated", "imgbbApiKey": "deprecated",
"geminiApiBaseUrl": "https://yunwu.ai", "geminiApiBaseUrl": "https://yunwu.ai",
@@ -34,4 +34,4 @@
"ttsModel": "cosyvoice-v3.5-plus", "ttsModel": "cosyvoice-v3.5-plus",
"ttsVoice": "cosyvoice-v3.5-plus-bailian-fa8787c0f70b4ba2a907c35511e6a6f6", "ttsVoice": "cosyvoice-v3.5-plus-bailian-fa8787c0f70b4ba2a907c35511e6a6f6",
"ttsLanguage": "Chinese" "ttsLanguage": "Chinese"
} }

View File

@@ -155,6 +155,9 @@ function registerDraft(draftId, draftName, totalDurationUs) {
const rootMetaPath = path.join(jianyingDraftPath, 'root_meta_info.json') const rootMetaPath = path.join(jianyingDraftPath, 'root_meta_info.json')
const draftDir = path.join(jianyingDraftPath, draftId) const draftDir = path.join(jianyingDraftPath, draftId)
if (!fs.existsSync(rootMetaPath)) {
fs.writeFileSync(rootMetaPath, JSON.stringify({ all_draft_store: [] }, null, 4), 'utf-8')
}
const rootMeta = JSON.parse(fs.readFileSync(rootMetaPath, 'utf-8')) const rootMeta = JSON.parse(fs.readFileSync(rootMetaPath, 'utf-8'))
if (rootMeta.all_draft_store.some(d => d.draft_fold_path === winPath(draftDir))) { if (rootMeta.all_draft_store.some(d => d.draft_fold_path === winPath(draftDir))) {
console.log(' 已注册,跳过') console.log(' 已注册,跳过')