You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ssml): spell_out splits combining marks and regional-indicator pairs #2825
backend/services/ssml_lite.py:spell_out iterates by Python str codepoints, so a single visible character built from a base plus one or more combining marks (NFD-decomposed) is split into multiple space-separated units. The same happens to paired regional-indicator sequences (flag emoji), even though the JS-side SSML-LITE path was already fixed by 55f3d58 fix(ssml): spell out by grapheme.
Repro
importunicodedatafromservices.ssml_liteimportspell_out# NFD: 'é' = e + U+0301print(spell_out(unicodedata.normalize('NFD', 'café')))
# c a f e ́ (the combining acute stands alone; TTS will drop it)# regional indicators: '🇺🇸' = U+1F1FA U+1F1F8print(spell_out('🇺🇸'))
# 🇺 🇸 (a single character announced as two)
The correct output is the same as the composed / precomposed form (c a f é, 🇺🇸). The same bug does not exist for NFC text because precomposed characters are a single codepoint, but the function is reachable from longform_parser.py for any audiobook / longform line that originated in a Mac keyboard buffer or an editor that emits NFD (Pages, TextEdit, Vim with decompose on, copy-paste from a web page).
Suggested fix
Segment by grapheme cluster using only stdlib: NFC-normalize first (handles decomposed Latin/Hangul), then group trailing unicodedata.combining(c) characters onto the previous base. The narrow fix covers the common audiobook cases without adding a new dependency. Regional-indicator / ZWJ emoji remain a separate, smaller follow-up (a real grapheme library would be the right tool, and would also have to land in the locked deps).
Activity