如何在 google 文本转语音中使用拼音或音素发音?

How to use Phonetic or Phoneme pronunciation in google text to speech?

我已经尝试了一段时间让语音或音素发音与 google's text to speech 一起工作,但未能始终如一地执行。

我使用 https://tophonetics.com/ 获得的结果有限 它将 "The cow went mad." 翻译成“ðə kaʊ wɛnt mæd”。但是 'the' 'ðə' 听不见。当我尝试“ðɪs ɪz səm fəˈnɛtɪk tɛkst ˈɪnˌpʊt”时。

是否有任何 SSML 代码来定义语音文本块, 可以是这种格式 "D,Is Iz sVm f@n'EtIk t'Ekst 'InpUt" 可以用来代替“ðɪs ɪz səm fəˈnɛtɪk tɛkst ˈɪnˌpʊt” “

SSML 标签 <phoneme> 可满足您的需求。

遗憾的是,Google 云 Text-to-speech 目前不支持它。 Google Cloud 的可用 SSML 标签子集在 documentation. The <phoneme> tag is not in this list. An experiment using Google Cloud's text-to-speech-demo 中列出确认音素被忽略。标签的内容被当作普通文本阅读,正如@Trevor 在评论中所指出的那样。

但是,<phoneme> 标签受到 Microsoft Azure Text-to-Speech 和 Amazon Polly 的支持。在这两种情况下,可用的音素仅限于所用语言中可用的音素(请参阅 here for Azure and here for Polly). The Azure documentation isn't 100% clear about the exclusion of out-of-language phonemes, but practical experiments with the Azure Text-to-Speech demo 确认它们无法正常工作。在某些情况下,它们至少似乎被最接近的可用等价物所取代使用的语言。

仅限于一种语言的音素严重限制了音素标签的实用性。例如,您不能使用该功能以第二语言嵌入正确发音的内容,因为第二语言通常会有一些第一语言没有的音素。每种语言都有一些另一种语言没有的音素的具体语言对是 English/German、Spanish/German、English/Spanish.

Google Text-to-Speech 至少从 spring 2021 年开始支持 <phoneme> 标签。

但是,有很多潜在的陷阱需要克服:

  • demo page filters out <phoneme> tags on the client side before they even reach the API. (It does the same with the <voice> tag as pointed out here)
  • 与 Microsoft Azure 文本转语音一样(请参阅可以使用的 for details), each language only supports a limited set of phonemes(“字母”)。
  • 如果您使用不受支持的标签,音素标签将在没有任何警告的情况下被完全忽略。所以官方示例 <phoneme alphabet="ipa" ph="ˌmænɪˈtoʊbə">manitoba</phoneme> 不适用于任何英语变体,但 en-US,因为所有其他人都缺少 "o""oʊ" 音素。
  • 不清楚您是否需要使用 v1beta1 API(我可以确认它正在运行)或者版本 v1 是否也可以。