dsh-line-bot 0.10.7 → 0.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/client.js +1 -1
- package/lib/host.mjs +1 -1
- package/lib/tts.mjs +12 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/client.js
CHANGED
|
@@ -1428,7 +1428,7 @@ window.__ModuleLoader__.load({
|
|
|
1428
1428
|
h(Btn, { onClick: () => voiceInputRef.current && voiceInputRef.current.click(), disabled: !!busy }, '上傳參考音'),
|
|
1429
1429
|
h('input', { ref: voiceInputRef, type: 'file', accept: 'audio/*', style: { display: 'none' }, onChange: uploadVoice }),
|
|
1430
1430
|
),
|
|
1431
|
-
h('div', { style: S.hint }, '目前參考音:' + (voiceStatus.reference?.path || '(尚未設定,預設會用插件內建的 12–16 秒片段)')),
|
|
1431
|
+
h('div', { style: S.hint }, '目前參考音:' + (voiceStatus.reference?.path || '(尚未設定,預設會用插件內建的 12–16 秒片段)') + '(上傳後會自動去開頭靜音並裁到前 15 秒)'),
|
|
1432
1432
|
voiceStatus.reference?.path ? h('div', { style: S.row }, h(Btn, { onClick: resetVoiceReference, disabled: !!busy }, '改用內建預設參考音')) : null,
|
|
1433
1433
|
h('div', { style: S.grid },
|
|
1434
1434
|
h(Field, { label: '引擎', hint: 'auto 會依系統自動挑選' }, h('select', { value: voiceCfg.provider || 'auto', onChange: (event) => update({ voice: { provider: event.target.value } }), style: S.input }, ['auto', 'mlx', 'gguf'].map((item) => h('option', { key: item, value: item }, item)))),
|
package/lib/host.mjs
CHANGED
|
@@ -51,7 +51,7 @@ const { createVision } = visionMod
|
|
|
51
51
|
const { createTts } = ttsMod
|
|
52
52
|
const { chunkText, clip, inQuietWindow, jsonFail, jsonOk, maskSecret, readJsonBody, safeArray, sleep, readJsonSafe } = utilMod
|
|
53
53
|
|
|
54
|
-
export const VERSION = '0.10.
|
|
54
|
+
export const VERSION = '0.10.8'
|
|
55
55
|
|
|
56
56
|
// 環境變數提供的 Cloudflare API Token(方便用 shell 注入、不用把 token 寫進設定檔)。
|
|
57
57
|
// 設定檔裡的 token 優先;兩者都沒有時才用環境變數。
|
package/lib/tts.mjs
CHANGED
|
@@ -619,8 +619,19 @@ export function createTts({ dir, logger, getConfig }) {
|
|
|
619
619
|
const ffmpeg = which('ffmpeg')
|
|
620
620
|
if (!ffmpeg) throw new Error('需要 ffmpeg 才能轉換音檔')
|
|
621
621
|
const dest = path.join(paths.refDir, `upload-${Date.now()}.wav`)
|
|
622
|
-
|
|
622
|
+
// 語音克隆只需要一小段乾淨的人聲;整段 10 幾分鐘的錄音會讓模型合成卡死。
|
|
623
|
+
// 先去掉開頭靜音,再取前 15 秒(失敗時退回單純截前 15 秒)。
|
|
624
|
+
const trimArgs = ['-hide_banner', '-loglevel', 'error', '-y', '-i', src,
|
|
625
|
+
'-af', 'silenceremove=start_periods=1:start_duration=0.2:start_threshold=-40dB,atrim=0:15,asetpts=N/SR/TB',
|
|
626
|
+
'-ac', '1', '-ar', '16000', '-c:a', 'pcm_s16le', dest]
|
|
627
|
+
try {
|
|
628
|
+
await run(ffmpeg, trimArgs, { timeout: 120000 })
|
|
629
|
+
if (referenceInfoFor(dest).seconds < 1) throw new Error('裁切後沒有聲音')
|
|
630
|
+
} catch {
|
|
631
|
+
await run(ffmpeg, ['-hide_banner', '-loglevel', 'error', '-y', '-i', src, '-t', '15', '-ac', '1', '-ar', '16000', '-c:a', 'pcm_s16le', dest], { timeout: 120000 })
|
|
632
|
+
}
|
|
623
633
|
const info = referenceInfoFor(dest)
|
|
634
|
+
try { fs.unlinkSync(src) } catch { /* 原始上傳檔可留可不留 */ }
|
|
624
635
|
return { path: dest, ...info }
|
|
625
636
|
}
|
|
626
637
|
|