Skip to content

pocket_tts: end the prompt like the reference and PocketTTS Small - #1368

Merged
0xShug0 merged 2 commits into
0xShug0:mainfrom
unaltolga:fix/pocket-tts-terminal-punctuation
Nov 23, 2026
Merged

0xShug0 merged 2 commits into
0xShug0:mainfrom
unaltolga:fix/pocket-tts-terminal-punctuation

Conversation

@unaltolga

Copy link
Copy Markdown
Contributor

What

prepare_pocket_tts_text added a period only when the prompt ended in a letter or a digit. The reference (_ensure_terminal_punctuation in pocket-tts prepare_text_prompt) and this repo's own PocketTTS Small do more. Past any closing quotes or brackets, a sentence mark is kept, a trailing comma, semicolon, colon, hyphen or dash becomes a period, and any other ending gets a period after the closers. The model is trained on sentences that end in one of .!?….

Package Input main this PR (and the Python reference)
english He looked up and said "we should go home" unchanged He looked up and said "we should go home".
english The meeting moved to Friday (after lunch) unchanged The meeting moved to Friday (after lunch).
english Bring the maps, the water, and the tent, unchanged Bring the maps, the water, and the tent.
english She paused for a moment - unchanged She paused for a moment.
english Tickets cost 25 € unchanged Tickets cost 25 €.
german Das Treffen ist am Freitag – Das Treffen ist am Freitag , Das Treffen ist am Freitag.
french Prends les cartes, l’eau et la tente, Prends les cartes, l'eau et la tente, Prends les cartes, l'eau et la tente.

Changes

  • The ending check in prepare_pocket_tts_text is now the one pocket_tts_small/conditioning.cpp uses.
  • is_letter_or_digit had no other caller and is removed. An accented final letter still gets its period (C'est réglé.), because the new rule appends one after anything that is not a sentence mark.

Validation

macOS 27.2 on an Apple M2, CPU backend, with the q8_0 packages. The text check and ctest are on cf49294; the WER runs were on fe6d153, and nothing under src/models/pocket_tts has changed since.

  • Same text and token ids as the Python reference. With the probe from pocket_tts: apply the config's replace_characters like the reference #1339 I ran 24 lines (14 English, 4 French, 3 German, 3 Spanish) that end in closing quotes, brackets, commas, colons, hyphens, dashes, €, … and sentence marks. I compared them with pocket-tts prepare_text_prompt from main (a4a6054), called with that language's upstream config and the package's own tokenizer.model. The prepared text and the token ids match on all 24 lines. On main, 14 of them differ.
  • Runtime, before and after. I synthesized those 14 sentences with audiocpp_cli built from main and from this branch (seeds 1 to 4; voice alba, cosette for French). I transcribed them with Whisper small and scored WER against the words to be spoken. The sentences are short, and the model reads most of them correctly without the period: 360 words, main 7.8%, this PR 6.4%; 3 sentences better, 0 worse, 11 the same. So the main reason for the change is to match the reference and PocketTTS Small.
  • ctest: 115 of 119 pass from the build directory, and the other 4 pass when run from the repository root, as in pocket_tts: apply the config's replace_characters like the reference #1339 and pocket_tts: give the built-in defaults the upstream text options #1352.

AI disclosure: written with Claude Code (Claude Opus 5.5). I reviewed the change, and the results above are from real runs on my Mac.

Port _ensure_terminal_punctuation from PocketTTS Small: past closing quotes
and brackets, a trailing comma, colon or dash becomes a period, and any other
ending that is not a sentence mark gets a period after the closers. Before,
only a final letter or digit got one.
@0xShug0

0xShug0 commented Nov 22, 2026

Copy link
Copy Markdown
Owner

@unaltolga Thanks for the PR. Two issues:

  1. Gradium shares PocketTTSSession, but its upstream only appends punctuation after a trailing letter or digit. It preserves existing trailing punctuation.

Input: Please bring the maps and the water,

Main PR Gradium upstream
Please bring the maps and the water, Please bring the maps and the water. Please bring the maps and the water,

Please use the existing PocketTTSImplementation routing table method to select the terminal-punctuation policy per model. Apply the new upstream rule to PocketTTS while preserving Gradium Phonon’s existing behavior.

  1. PocketTTS can produce a closing-quote-only chunk.

Input: He stopped at the doorway. “I know you asked me not to say anything about what happened that night but I cannot keep pretending that everything is fine when your sister still believes that I was the one who—”
default 50-token budget

Main PR PocketTTS upstream
2 chunks 3 chunks; the last contains only ” 2 chunks

…with their sentence

Gradium Phonon shares the session but its upstream only adds a period after a
final letter or digit. PocketTTSImplementation now carries the prompt
punctuation rule; PocketTTS takes the reference rule and Gradium keeps the old
one.

With the reference ending, a prompt that ends in a dash and a closing quote
became 'who.”' and the splitter left the quote as a chunk of its own. The
splitter now skips the closers right after a sentence mark, like the
reference's _skip_closers, for PocketTTS only.
@unaltolga

Copy link
Copy Markdown
Contributor Author

Thanks for checking both. Pushed 5a2a8bc:

  1. PocketTTSImplementation now carries a prompt_punctuation rule. pocket_tts uses the reference ending, and kGradiumPhononImplementation sets PromptPunctuation::LetterOrDigit, the previous rule: a final letter or digit gets a period, and any other ending is kept. With the English assets run through the Gradium implementation, Please bring the maps and the water, stays as it is.

  2. The splitter now does what the reference's _skip_closers does: closing quotes and brackets right after a sentence mark stay with their sentence instead of starting the next segment. This applies to PocketTTS only, so Gradium's chunks don't change. Your example gives 2 chunks again, and the second one ends in who.”. I compared split_into_sentence_chunks with pocket-tts split_into_best_sentences (main a4a6054) on 7 English lines with closing quotes and brackets, at budgets of 50 and 8 tokens, and the chunks match on every line. It also removes a space that main adds before a closer when it joins segments: “Stop.” He left without another word. reached the model as “Stop. ” He left without another word.

The 24-line text and token check against the reference still matches. ctest is unchanged: 115 of 119 pass from the build directory, and the other 4 pass from the repository root.

@0xShug0
0xShug0 merged commit da0a7aa into 0xShug0:main Nov 23, 2026
7 checks passed
@0xShug0

0xShug0 commented Nov 23, 2026

Copy link
Copy Markdown
Owner

@unaltolga Thanks! PR merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants