Creating Alexa Skills using Audio Files
The Alexa platform has the ability to develop custom skills and it is handled by AWS. Not only simple responses, but there are also more tasks 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 S3 bucket for storage of audio tracks.
- Create an Alexa skill from Alexa console.
- Create Interaction model.
- Connect your lambda function with Alexa skill.
- Code in Lambda function with desired SSML tags.
The audio file in 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 file according to Alexa-Friendly Format.
- Open the file to convert in Audacity.
- Set the Project Rate in the lower-left corner to
- Click File > Export Audio and change the Save as type to
- Click Options, set the Quality to
48 kbpsand the Bit Rate Mode to
The task of playing audio files can be achieved by using any language example nodejs or python. It needs some important tags termed as 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>
- 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