Repository navigation
sanotts: return word timestamps with the NEON decoder - #1221
Conversation
Port the duration-based word timestamps onto the NEON decoder branch. The synthesize path can report each token's frame count, and the session turns those into word spans when return_timestamps is requested. Co-Authored-By: Claude Haiku 5.5 <[email protected]>
|
@tarelerulz Thanks for the PR! Two potential issues found: (1) Word labels contain phonemes. "Hello world" returns "həlˈO, wˈɜɹld". Is this expected? (2) Punctuation merges words. "Hello,world!" produces one span because punctuation doesn’t terminate the current word. |
Word spans were built from phoneme symbols, so labels read as IPA
("həlˈO"), and punctuation tokens were skipped without ending the current
word, so "Hello,world!" merged into one span.
Labels now come from the chunk text: runs between whitespace and
word-end marks. Phoneme groups (runs between spaces and word-end marks)
pair with them by index. Apostrophes and hyphens stay inside a word.
If the counts disagree, the chunk gets one span labeled with its text
rather than words attached to the wrong audio.
Co-Authored-By: Claude Haiku 5.5 <[email protected]>
|
Thanks for catching these. Both are fixed in 979d336 on this branch.
Testing: a standalone harness with synthetic token sequences passes 6/6 cases (comma with and without a space, apostrophe/hyphen, dash and curly quotes, count mismatch, empty input), and session.cpp passes a syntax check. I have not yet rebuilt the library and run the Heart voice end to end on the Pi, so the real espeak word grouping is still unverified. I'll run that next and report back here. |
Phoneme groups and text words can disagree: espeak merges words with no
space ("was a" -> one group) and splits some words ("$5" -> two groups).
Index pairing then labeled whole sentences as one span.
When the counts differ, each word is phonemized alone and its phonemes
are aligned to the stream's phonemes by edit distance. Frames are spread
over each group's phonemes, so a shared group is split in time. If fewer
than half the phonemes match, the chunk still gets one span.
The word-timestamp helpers move to word_timestamps.{h,cpp}, which take
the symbol lookup and per-word phonemizer as arguments. New unit test
sanotts_word_timestamps_test covers merged, split and poor-match cases.
Tested: unit test passes on Pi and Pixel 9 VM. Heart clips through the
CLI and server: all word labels match the text. Word starts vs the canary
CTC aligner on six clips: 83 words, median |err| 0.048 s, 96% within 0.25 s.
Co-Authored-By: Claude Haiku 5.5 <[email protected]>
|
Follow-up on the two issues from earlier. New commit Fixed
What changed: when the phoneme groups and the text words don't line up, each word is pronounced on its own and aligned to the phoneme stream by edit distance. The word helpers moved to Testing
Timing accuracy: I compared word start times with |
|
@tarelerulz Thanks! PR merged. |
Summary
return_timestampsis requested, so the NEON decoder (sanotts.cpu_decoder=neon) can serve read-along timing as well as audio.SanoTtsFrontend::symbol_for_idfor the token-to-symbol lookup.Testing
origin/mainat d2da530).🤖 Generated with Claude Code