2017-05-08 39 views
1

我正在嘗試在我的Alexa技能中使用SSML。我使用Lambda作爲服務端點,並使用Js對其進行編程。現在我的問題是,我如何在我的技能中正確實施?我使用下面的函數使用SSML:如何在Alexa技巧+ Lambda + Js中使用SSML

function buildSSMLSpeechletResponse(title, output, repromptText, shouldEndSession) { 
    return { 
     outputSpeech: { 
      type: "SSML", 
      ssml: output 
     }, 
     card: { 
      type: "Simple", 
      title: "SessionSpeechlet - " + title, 
      content: "SessionSpeechlet - " + output 
     }, 
     reprompt: { 
      outputSpeech: { 
       type: "SSML", 
       text: repromptText 
      } 
     }, 
     shouldEndSession: shouldEndSession 
    }; 
} 

我的代碼:

function onLaunch(launchRequest, session, callback) { 
    console.log("onLaunch requestId=" + launchRequest.requestId 
     + ", sessionId=" + session.sessionId); 

    var cardTitle = "Hello, World!"; 
    var speechOutput = { type: "SSML", 
    ssml: "<speak>Welcome to Hubo help. <amazon:effect name='whispered'>You can ask questions like</amazon:effect>: 'How do I paint a wall?'. Now what can I help you with?.</speak>", }; 
    callback(session.attributes, 
     buildSSMLSpeechletResponse(cardTitle, speechOutput, "", true)); 
} 

我想我在回調的錯誤呢?提前致謝!

回答

3

如果您使用的是Alexa Skills Kit SDK for Node.js,您可以在要發送的文本中包含SSML標記。

例如:

this.emit(':tell', 'Sometimes when I look at the Alexa skills you have all taught me, I just have to say, <say-as interpret-as="interjection">Bazinga.</say-as><break time="0.3s"/><amazon:effect name="whispered"> I love it. </amazon:effect>')

this.emit(':tell', '<say-as interpret-as="interjection">Oh boy</say-as><break time="1s"/> this is just an example.')

將包含在README.md文件,有this公關,現在