使用 SSML (interpret-as="characters") 删除标点符号

Using SSML (interpret-as="characters") removes punctuation

如果我在语音回复中使用 <say-as interpret-as="characters"></say-as> 标签,google 助手会突然以不同的方式发音整个回复。听起来好像google助手无缘无故地去掉了标点符号。由“.”发起的停顿突然消失了。

要重现此行为,只需在 google 模拟器上启动操作,选择 "English (United States)" 作为语言并收听此音频片段:

<speak>This is a test with number spelled as digit. The number is <say-as interpret-as="characters">12345</say-as>. Ask me "What to do with this number?" if you'd like to have more information.</speak>

如果删除 <say-as interpret-as="characters"></say-as> 标签,发音将再次生效:

<speak>This is a test with number spelled as digit. The number is 12345. Ask me "What to do with this number?" if you'd like to have more information.</speak>

现在听起来应该如此。如果完全省略 speak 标记,您将得到相同的结果。

在德语中,这个问题更为严重。在德语语音响应中使用 <say-as interpret-as="characters"></say-as> 会导致几乎无法理解的响应。

这是因为 Google Google 助理的 TTS 进程中的 "text normalization"。

因此,如果您使用 <say-as>.

等嵌入式标记,不使用 <s> 元素的 SSML 将不会始终执行您期望的暂停操作

这是一个使用 <s> 在 TTS 中提供预期停顿的示例:

<speak>
  This is a test with number spelled as digit.
  <s>The number is <say-as interpret-as="characters">12345</say-as>.</s>
  Ask me "What to do with this number?" if you'd like to have more information.
</speak>

您仍然可以随意将多个句点分隔的句子输入 SSML,而无需 <s> 分隔句子,只要您不使用嵌入式标记,让 Google 助手处理中断生成像 <say-as>.

有关 <s> 元素的更多信息可以在文档中找到 <p>,<s> https://developers.google.com/actions/reference/ssml

它会link到W3C spec on those elements