fix(azure): nest <prosody> inside <voice>, not as direct child of <speak>#39
Merged
Merged
Conversation
…eak> When rate, pitch, or volume were passed as options to ensureAzureSSMLStructure, the prosody element was being extracted from inside <speak> rather than from inside <voice>. This produced invalid SSML that Azure rejects with: "Node [speak] with type [RootSpeak] should not contain node [prosody] with type [Others]." Fix: when a <voice> element is present, replace content inside <voice> (mirroring the existing this.properties branch above). Add regression test. Fixes #38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
rate,pitch, orvolumeare passed as options tosynthToBytestream/synthToBytes, the generated SSML places<prosody>as a direct child of<speak>instead of inside<voice>:Azure rejects this with HTTP 500:
Root cause
In
ensureAzureSSMLStructure, thethis.propertiesbranch (rate/pitch/volume set on the client) correctly extracts content from inside<voice>. But theoptionsbranch (rate/pitch/volume passed per-call) always extracted from inside<speak>, so once<voice>had been injected earlier in the same method, the prosody ended up wrapping it from the outside.Fix
Mirror the
this.propertiesbranch in theoptionsbranch: when<voice>is present, replace content inside<voice>; only fall back to<speak>when no<voice>element exists.Test
Added regression test in
azure-mstts-namespace.test.tsthat asserts<prosody>appears after<voice>in the output and matches/<voice[^>]*>\s*<prosody[^>]*>/.Closes #38