fix TTS cutoff: lower chunk limit to 1500 chars, fix code block regex for backtick content
This commit is contained in:
parent
8845d22ce9
commit
b7ac2cbf3a
1 changed files with 3 additions and 3 deletions
|
|
@ -82,7 +82,7 @@ const ttsCache = new Map();
|
|||
|
||||
// Split long text into chunks at sentence boundaries for TTS API limits
|
||||
// OpenAI-compatible TTS endpoints typically cap at ~4096 characters
|
||||
const TTS_CHUNK_MAX = 3800; // leave headroom under 4096
|
||||
const TTS_CHUNK_MAX = 1500; // conservative limit for TTS server compatibility
|
||||
|
||||
function splitTextIntoChunks(text) {
|
||||
if (text.length <= TTS_CHUNK_MAX) return [text];
|
||||
|
|
@ -122,7 +122,7 @@ function splitTextIntoChunks(text) {
|
|||
remaining = remaining.substring(splitAt).trim();
|
||||
}
|
||||
|
||||
console.log(`TTS: split ${text.length} chars into ${chunks.length} chunks`);
|
||||
console.log(`TTS: split ${text.length} chars into ${chunks.length} chunks:`, chunks.map((c, i) => `chunk${i + 1}=${c.length}chars`));
|
||||
return chunks;
|
||||
}
|
||||
|
||||
|
|
@ -136,8 +136,8 @@ function cleanTextForTTS(text) {
|
|||
.replace(/_([^_]+)_/g, '$1') // Italic alt
|
||||
.replace(/#+\s/g, '') // Headers
|
||||
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Links
|
||||
.replace(/```[\s\S]*?```/g, '') // Code blocks (lazy match handles backticks in code)
|
||||
.replace(/`([^`]+)`/g, '$1') // Inline code
|
||||
.replace(/```[^`]*```/g, '') // Code blocks
|
||||
// Remove HTML tags
|
||||
.replace(/<[^>]+>/g, '')
|
||||
// Remove excess whitespace
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue