Alexa SkillsVoice.WorksJanuary 24, 20190Creating Alexa Skills using Audio Files

https://www.datavizz.in/wp-content/uploads/2019/01/MicrosoftTeams-image-11.jpg

The Alexa platform has the ability to develop custom skills and it is handled by AWS. Not only simple responses but more tasks are that are performed by Alexa. Alexa can also be programmed to use with custom audios.

Steps to follow:

  • Create an AWS account.
  • Select a lambda service and create it.
  • Create an S3 bucket for the storage of audio tracks.
  • Create an Alexa skill from the Alexa console.
  • Create an Interaction model.
  • Connect your lambda function with the Alexa skill.
  • Code in Lambda function with desired SSML tags.

Note

The audio file in the Amazon S3 instance must have public permissions.
Take care of Language in Alexa Skill While developing. Set it according to your requirement example En-US or En-In.

How to make audio files according to Alexa-Friendly Format.

  1. Open the file to convert in Audacity.
  2. Set the Project Rate in the lower-left corner to 16000.
  3. Click File > Export Audio and change the Save as type to MP3 Files.
  4. Click Options, set the Quality to 48 kbps, and the Bit Rate Mode to Constant.

The task of playing audio files can be achieved by using any language example nodejs or python. It needs some important tags termed SSML tags, But what is SSML?

SSML is a markup language that provides a standard way to mark up text for the generation of synthetic speech. The Alexa Skills Kit supports a subset of the tags defined in the SSML specification.

It has its own syntax to append it with the skill code. For example

<speak>
    Welcome to Car-Fu. 
    <audio src="soundbank://aws.amazon/abc/car.mp3" /> 
    You can order a ride, or request a fare estimate. 
    Which will it be?
</speak>

Note

  • You can use SSML with both the normal output speech response and any re-prompt included in the response.
  • If you use the Alexa Skills Kit SDK for Node.js or Alexa Skills Kit SDK for Java, you do not have to include the tag for the SSML you provide, as that is handled by the SDK. Otherwise, the SSML you provide must be wrapped within tags.

For more information about SSML tags visit.
https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html

Let’s take an example of using SSML tags with python Ask SDK.

class LaunchRequestHandler(AbstractRequestHandler):
   def can_handle(self, handler_input):
   return is_request_type("LaunchRequest")(handler_input)
   def handle(self, handler_input):
      logger.info("In LaunchRequestHandler")
      speech = ("<speak>Welcome to the world of Marvel.<audio   src="https://s3.amazonaws.com/abxz/abc_ring.mp3"/><break time="1s"/>Listen to the  rules carefully <break time="1s"/> Its Simple. an audio will play  and you have to guess the Marvel Character! Say start game to  Start<break time="1s"/> End game to stop </speak>")
     reprompt = "Please say Start Game to Start."
     handler_input.response_builder.speak(speech).ask(reprompt)
     return handler_input.response_builder.response
Note - No need to import any libraries for SSML tags to work
Supported SSML Tags
Share

Leave a Reply

Your email address will not be published. Required fields are marked *