diff --git a/tts_bridge.js b/tts_bridge.js index bf5764c..22db2c3 100644 --- a/tts_bridge.js +++ b/tts_bridge.js @@ -192,6 +192,7 @@ function spellWord(word) { const PUNCT_MAP = { ",": "、", ".": "。", "!": "!", "?": "?", ",": "、", "。": "。", "!": "!", "?": "?", + " ": "、", // AquesTalk truncates on space; use 、 pause instead }; function wordToKana(word) { @@ -227,7 +228,7 @@ function convertEnglishSegment(text) { for (const token of words) { if (/^\s+$/.test(token)) { - parts.push(" "); // keep word gap for AquesTalk pause + parts.push("、"); // word gap: AquesTalk truncates on space, use 、 instead continue; } if (PUNCT_MAP[token] !== undefined) { @@ -237,7 +238,7 @@ function convertEnglishSegment(text) { parts.push(wordToKana(token)); } - return parts.join("").replace(/ +/g, " "); + return parts.join("").replace(/、+/g, "、"); } function synthesize(kanaText) { @@ -265,6 +266,9 @@ function synthesize(kanaText) { result += convertEnglishSegment(englishBuf); } + // Collapse consecutive pauses; strip any residual spaces (AquesTalk truncates on space) + result = result.replace(/ +/g, "、").replace(/、+/g, "、").replace(/^、|、$/g, ""); + console.error(`[bridge] SYNTH IN: ${trimmed}`); console.error(`[bridge] SYNTH OUT: ${result}`);