在行动中改变声音

Change voice in Action

如何在 "Actions on Google" 回复时改变声音?有没有SSML代码可以在读一段话的时候临时改变声音,比如从男声变成女声?

您目前无法更改语音,但您可以使用语音合成标记语言 (SSML) 以获得更多可自定义(=音频)响应。

有关如何将 SSML 与 Action On Google 结合使用的更多信息:https://medium.com/google-developers/ssml-for-actions-on-google-946117f97fd1

希望对您有所帮助。

实际上,您可以通过在说话标签内添加语音标签来更改语音。你可以尝试这样的事情:

<speak><voice gender="female">Hello I'm Mary</voice><break time="2s"/><voice gender="male">Hey I'm John</voice><speak>

最佳解决方案。

const request = {
    // The text to synthesize
    input: { 
      ssml:`<speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.w3.org/2001/10/synthesis
                 http://www.w3.org/TR/speech-synthesis11/synthesis.xsd"
       xml:lang="en-US">   
  <voice gender="female" languages="en-US" required="languages gender variant">It Maria and this is my female voice,</voice>
  <!-- processor-specific voice selection -->
  <voice name="Mike" required="name">Its Mike and its my male voice</voice>
</speak>`
    },

    // The language code and SSML Voice Gender
    voice: { languageCode: 'en-US', ssmlGender: 'NEUTRAL' },

    // The audio encoding type
    audioConfig: { audioEncoding: 'MP3' },
  };

这对我来说太棒了