[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"lab-entry-azure-tts-timings-fail-silently":3},{"entry":4,"newer":19,"older":24},{"slug":5,"tag":6,"issueNumber":7,"publishedAt":8,"title":9,"excerpt":10,"readingTimeMinutes":11,"updatedAt":8,"bodyHtml":12,"cover":13,"videoUrl":13,"links":14,"stack":15,"nextStep":13},"azure-tts-timings-fail-silently","Lesson",8,"2026-11-27T05:39:28.188557+00:00","Azure text-to-speech timings fail silently, so check word and bookmark events against your script","For anyone timing captions or animation to Azure text-to-speech: some voices glue punctuation to a word in word-boundary events, and two SSML bookmarks placed back to back lose one, both with no error. Rebuild the word list from your script, keep one bookmark per spot, and fail the build when the timings don't match what you sent.",4,"\u003Ch3>The story\u003C\u002Fh3>\n\u003Cp>I was building a narrated explainer video where every caption and drawing is timed from the voice-over. The narration came from Azure text-to-speech, which can hand back two kinds of timing. Word-boundary events give the time of each spoken word. Bookmarks are named markers you place in the SSML, the XML-style markup that tells a speech service how to read a script, and each one comes back with a timestamp. I used the word times for captions, and a \u003Ccode>&lt;bookmark mark=&quot;...&quot;\u002F&gt;\u003C\u002Fcode> before each paragraph to start its drawings.\u003C\u002Fp>\n\u003Cp>Both kinds of timing broke, and neither raised an error.\u003C\u002Fp>\n\u003Cp>The first problem showed up in a short sample of scene 1 that I made in two voices to compare them. The word list from the Ava voice didn't match my script, even though the audio sounded fine. When I logged the raw events, I found Ava sends a closing quote and the next name, \u003Ccode>” Anna\u003C\u002Fcode>, as a single word. The text offsets also drift after quotes, so a caption can slip against the audio.\u003C\u002Fp>\n\u003Cp>The second showed up with the full script and its 66 bookmarks. The narration rendered with no error and no warning, but the scene and recall marks were missing from the timings. A scene marker had landed right next to a paragraph marker with no spoken words between them, and Azure had kept only one of the two.\u003C\u002Fp>\n\u003Ch3>Why I'm sharing this\u003C\u002Fh3>\n\u003Cp>Anyone who syncs captions, karaoke-style highlighting, slides or animation to Azure text-to-speech can hit both. The audio is fine each time, so you find out late: a caption drifts, or a picture shows up at the wrong moment or never, usually after a long render. The word problem also depends on the voice, so a voice that works today can break when you switch.\u003C\u002Fp>\n\u003Ch3>The fix\u003C\u002Fh3>\n\u003Cp>The rule behind both fixes: don't trust the timing events as they come back. Check them against the script you sent.\u003C\u002Fp>\n\u003Ch4>Words: split the events and match them to the script\u003C\u002Fh4>\n\u003Cp>Don't treat each event as one word. Split every event's text into words, then match them in order against the words of the text you sent in the SSML, and take each word's time from its matching event. Then check each voice by diffing the resulting word list against the script, paragraph by paragraph.\u003C\u002Fp>\n\u003Ch4>Bookmarks: one per spot, and fail when one goes missing\u003C\u002Fh4>\n\u003Cp>Keep one bookmark per spot. If two markers would sit next to each other, merge them or move one next to a spoken word. Then make the synthesis step fail when any bookmark you sent doesn't come back:\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-js\">\u003Cspan class=\"hljs-comment\">\u002F\u002F ssml: the text you sent; returned: mark names from the bookmark events\u003C\u002Fspan>\n\u003Cspan class=\"hljs-keyword\">const\u003C\u002Fspan> sent = [...ssml.\u003Cspan class=\"hljs-title function_\">matchAll\u003C\u002Fspan>(\u003Cspan class=\"hljs-regexp\">\u002F&lt;bookmark mark=&quot;([^&quot;]+)&quot;\u002Fg\u003C\u002Fspan>)].\u003Cspan class=\"hljs-title function_\">map\u003C\u002Fspan>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C\u002Fspan> =&gt;\u003C\u002Fspan> m[\u003Cspan class=\"hljs-number\">1\u003C\u002Fspan>]);\n\u003Cspan class=\"hljs-keyword\">const\u003C\u002Fspan> missing = sent.\u003Cspan class=\"hljs-title function_\">filter\u003C\u002Fspan>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">name\u003C\u002Fspan> =&gt;\u003C\u002Fspan> !returned.\u003Cspan class=\"hljs-title function_\">includes\u003C\u002Fspan>(name));\n\u003Cspan class=\"hljs-keyword\">if\u003C\u002Fspan> (missing.\u003Cspan class=\"hljs-property\">length\u003C\u002Fspan>) \u003Cspan class=\"hljs-keyword\">throw\u003C\u002Fspan> \u003Cspan class=\"hljs-keyword\">new\u003C\u002Fspan> \u003Cspan class=\"hljs-title class_\">Error\u003C\u002Fspan>(\u003Cspan class=\"hljs-string\">&#x27;Azure dropped bookmarks: &#x27;\u003C\u002Fspan> + missing.\u003Cspan class=\"hljs-title function_\">join\u003C\u002Fspan>(\u003Cspan class=\"hljs-string\">&#x27;, &#x27;\u003C\u002Fspan>));\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch4>How I checked it\u003C\u002Fh4>\n\u003Cp>After the word change, both voices gave word lists that matched the script exactly. After the bookmark change, I re-ran the full narration: every bookmark came back, and all 779 words matched the script, paragraph by paragraph.\u003C\u002Fp>\n\u003Ch3>Use it in your workflow\u003C\u002Fh3>\n\u003Cpre>\u003Ccode class=\"language-text\">My project sends SSML to Azure text-to-speech and uses the returned word-boundary events and &lt;bookmark mark=&quot;...&quot;\u002F&gt; events to time captions and visuals. Two things fail silently: some voices send punctuation attached to a word (a closing quote plus a name) as one word event, with text offsets that drift after quotes; and Azure drops the first of two bookmarks that have no spoken text between them. In &lt;repo&gt;, find where the SSML is built and where both kinds of event are read. (1) Split each word event's text into words and match them in order against the words of the SSML text, taking each word's time from its event. (2) Make the SSML builder never emit two bookmarks back to back; merge them or move one next to a word. (3) After synthesis, fail with a clear error if the word list differs from the script in any paragraph, or if any bookmark sent is missing from the events returned. Add tests for both failures, and run the word check for every voice we use.\n\u003C\u002Fcode>\u003C\u002Fpre>\n",null,[],[16,17,18],"Azure Speech","SSML","Node.js",{"slug":20,"tag":6,"issueNumber":21,"publishedAt":22,"title":23},"claude-code-installer-looks-stuck",9,"2026-11-30T11:07:50.420565+00:00","The Claude Code installer for Windows looks stuck because it downloads without progress",{"slug":25,"tag":6,"issueNumber":26,"publishedAt":27,"title":28},"load-rules-and-tools-where-needed",6,"2026-11-23T09:06:38.249092+00:00","Claude Code: load rules by file path and MCP servers per project"]