fix(azure): fix double-prosody and 0-1 volume scale when options are provided#41
Merged
Merged
Conversation
…are provided Two bugs in ensureAzureSSMLStructure when rate/pitch/volume options are passed: 1. Double-nested <prosody>: this.properties defaults (rate="medium", pitch="medium", volume=100) are always truthy, so the first block always added a default prosody, then the options block wrapped it with a second one. Merged both blocks into one: options override properties defaults, and a prosody element is only emitted when at least one value differs from Azure's implicit defaults. 2. Volume scale: callers commonly pass volume as a 0-1 float (e.g. 0.8), but the template literal appended "%" directly, producing volume="0.8%" (essentially silent) instead of volume="80%". Values in the range (0, 1] are now treated as fractions and normalised to the 0-100 scale before formatting. Fixes #40
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.
Problems (fixes #40)
1. Double-nested
<prosody>this.propertiesdefaults (rate="medium",pitch="medium",volume=100) are always truthy, soensureAzureSSMLStructurealways entered the first prosody block and wrapped content with<prosody rate="medium" pitch="medium" volume="100%">. Whenoptionswere also provided, a second<prosody>element was then wrapped around that, producing invalid double-nested prosody:2. Volume scale mismatch
volumeinSpeakOptionsis typed0-100, but callers commonly pass a0-1float (e.g.0.8). The template literal appended%directly, producingvolume="0.8%"(essentially silent) instead ofvolume="80%".Fix
Merged the two separate prosody-building blocks into one. Options override
this.propertiesdefaults. A<prosody>element is only emitted when at least one attribute differs from Azure's implicit defaults (medium/medium/100). Values in the range(0, 1]for volume are detected as fractions and normalised to the0–100scale.Tests added
<prosody>element when options are provided<prosody>emitted when all values are at Azure defaultsvolume=0.8normalises tovolume="80%"not"0.8%"