Search code examples
alexa-skills-kitssml

Problems in adjusting rate/pitch in Alexa SSML


I was trying to adjust Alexa talking speed and pitch with following:

outputSpeech: {
            type: "SSML",
            ssml: "<speak><prosody pitch="+50%">higher pitch</prosody></speak>"
},

The execution result succeeded, however I noticed "ssml": "<speak><prosody pitch=NaN" and when I went to simulator test, Alexa responded There was a problem with the requested skill's response

So I tried couple things:

ssml: "<speak><prosody rate="150%">faster pace</prosody></speak>"

the execution result fails: "SyntaxError: Unexpected number",


Solution

  • Can you try escaping the double quotes inside prosody tag attributes using this \"

    "<speak><prosody pitch=\"+50%\">higher pitch</prosody></speak>"
    

    or use a single quote

      const speechOutput = '<speak><prosody pitch="+50%">higher pitch</prosody></speak>';
          return handlerInput.responseBuilder
          .speak(speechOutput)
          .getResponse();