Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/formatters/ssml/microsoft_azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ impl MicrosoftAzureSsmlFormatter {
match node.node_type {
NodeType::PlainText => Ok(node.text.clone()),
NodeType::TextModifier => self.format_azure_text_modifier(node),
// Azure's Speech service does not support the W3C SSML <mark>
// element: an utterance containing one synthesises zero audio,
// with no error from the service. Its documented equivalent is
// <bookmark mark="…"/> (fired as a Bookmark event instead of a
// named position).
NodeType::Mark => Ok(format!(
"<bookmark mark=\"{}\"/>",
self.base.escape_xml(&node.text)
)),
_ => self.base.format_node_internal(node),
}
}
Expand Down Expand Up @@ -447,6 +456,23 @@ mod tests {
assert!(result.is_ok());
}

#[test]
fn test_microsoft_azure_mark_emits_bookmark() {
// Azure has no W3C <mark> (it silently synthesises zero audio);
// the documented equivalent is <bookmark mark="…"/>.
let input = "A [mark: \"b1\"] in the text.";
let result =
SpeechMarkdownParser::to_ssml(input, crate::formatters::base::Platform::MicrosoftAzure);
assert!(result.is_ok());

let ssml = result.unwrap();
assert!(ssml.contains("<bookmark mark=\"b1\"/>"), "got: {ssml}");
assert!(
!ssml.contains("<mark"),
"W3C mark must not be emitted: {ssml}"
);
}

#[test]
fn test_microsoft_azure_with_section() {
let input = "#[angry] I am angry!";
Expand Down
Loading