amazon-web-servicesaws-lex

How to modify amazon lex output voice?


I am trying to create a voice bot with aws lex.

In that one of the intents response is "Your incident INC11111111 is closed"(text).

The above response is coming from a lambda function. Please check the code below.

let response = (event, data) => {
    let lambda_response = {     
   "sessionAttributes": {
      "incidentNo":  event.currentIntent.slots.INCIDENT_NO,
    },   
    "dialogAction": {     
        "type": "Close",
        "fulfillmentState": "Fulfilled",
        "message": {       
           "contentType": "PlainText",
           "content": "Hi " + data["User ID"].split('.')[0]+", Your Incident Number " +  "INC"+event.currentIntent.slots.INCIDENT_NO+ " is ," + data["Status"]
        },    
     } 
    };

    return lambda_response;
};

Ex Incident No: INC11111111

But the voice output is "your incident INC 1 crore 11 lakhs 11 thousand 1hundered eleven is closed".

What I am expecting is "Your incident INC ONE ONE ONE ONE ONE ONE ONE ONE is closed. thank you in advance.


Solution

  • You need to utilise SSML(Speech Synthesis Markup Language)

    Using SSML tags, you can customize and control aspects of speech, such as pronunciation, volume, and speech rate.

    There are a variety of directives that you can use in SSML to pronounce things differently. In your case say-as directive can be useful.

    As per the question edit, try these changes

        "message": {       
           "contentType": "SSML",
           "content": "<speak> Hi " + data["User ID"].split('.')[0]+", Your Incident Number <say-as interpret-as="characters">" +  "INC"+event.currentIntent.slots.INCIDENT_NO+ "</say-as> is ," + data["Status"] +"</speak>"
        },    
    

    Related reading : Announcing Responses Capability in Amazon Lex and SSML Support in Text Response