File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -850,9 +850,9 @@ function groupSentences(sentences, groupSize = 2) {
850850}
851851
852852// Build TTS chunks by character length, prefer ending at sentence boundaries.
853- // - maxChars: hard cap per chunk (default 1000 )
853+ // - maxChars: hard cap per chunk (default 500 )
854854// - If a single sentence exceeds max, split it on whitespace near the limit.
855- function buildTtsChunks ( text , { maxChars = 1000 } = { } ) {
855+ function buildTtsChunks ( text , { maxChars = 500 } = { } ) {
856856 const sents = splitIntoSentences ( text ) ;
857857 const chunks = [ ] ;
858858 let i = 0 ;
@@ -947,7 +947,7 @@ function startVoicePlaybackForMessage(message, voice) {
947947 cancelCurrentTtsJob ( ) ;
948948 const raw = stripNonSpokenParts ( message . content || '' ) ;
949949 if ( ! raw ) return ;
950- const chunks = buildTtsChunks ( raw , { maxChars : 1000 } ) ;
950+ const chunks = buildTtsChunks ( raw , { maxChars : 500 } ) ;
951951 if ( ! chunks . length ) return ;
952952
953953 const job = {
Original file line number Diff line number Diff line change 1+ import assert from 'node:assert/strict' ;
2+ import { readFile } from 'node:fs/promises' ;
3+
4+ export const name = 'TTS chunker: halved payload (500 char cap) wired in call site' ;
5+
6+ export async function run ( ) {
7+ const js = await readFile ( new URL ( '../src/main.js' , import . meta. url ) , 'utf8' ) ;
8+ const defMatch = js . match ( / f u n c t i o n \s + b u i l d T t s C h u n k s \s * \( t e x t , \s * \{ \s * m a x C h a r s \s * = \s * ( \d + ) \s * \} \s * = \s * \{ \} \) \s * \{ / ) ;
9+ const defaultMax = defMatch ? Number ( defMatch [ 1 ] ) : null ;
10+ assert . equal ( defaultMax , 500 , 'default maxChars must be 500' ) ;
11+
12+ const callMatch = js . match ( / b u i l d T t s C h u n k s \( r a w , \s * \{ \s * m a x C h a r s : \s * ( \d + ) \s * \} \s * \) / ) ;
13+ const callMax = callMatch ? Number ( callMatch [ 1 ] ) : null ;
14+ assert . equal ( callMax , 500 , 'startVoicePlaybackForMessage should request 500-char chunks' ) ;
15+ }
You can’t perform that action at this time.
0 commit comments