mstar.api_server.openai.speech_chunking

mstar.api_server.openai.speech_chunking#

Sentence chunking for /v1/audio/speech.

Long inputs are split into sentence groups that are synthesized as separate requests and played back in order. This keeps every autoregressive text-to-speech request inside the length its model was trained for, lets the engine batch the pieces of one long input like independent requests, and starts the second piece while the first is still streaming (see serving_speech). Splitting is purely textual and model-agnostic.

Functions

split_sentences(text[, max_chars, min_chars])

Group text into sentence chunks of at most max_chars characters.

mstar.api_server.openai.speech_chunking.split_sentences(text, max_chars=400, min_chars=24)[source]#

Group text into sentence chunks of at most max_chars characters.

Sentences are never cut unless one alone exceeds max_chars (then it is wrapped at clause boundaries, then spaces, then by length). A trailing fragment shorter than min_chars is merged into its predecessor so the model is not asked to voice a lone “Okay.” Returns [text] when nothing needs splitting and [] for blank input.

Parameters:
Return type:

list[str]