Change voice in Action

Viewed 2050

How do I change the voice during my response in "Actions on Google"? Is there an SSML code to temporarily change the voice, for example, from male to female, while reading a quotation?

3 Answers

Best Solution for that.

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' },
  };

That's work for me like a charm

Related