Terren Peterson
Published © Apache-2.0

Using Alexa Speechcons in a Skill

Trying to give your Alexa skill a little more character? Use Speechcons in a skill to hack the Alexa voice to show a little emotion.

EasyProtip1 hour446
Using Alexa Speechcons in a Skill

Things used in this project

Hardware components

Amazon Echo
Amazon Alexa Amazon Echo
Or any other Alexa enabled device.
×1

Software apps and online services

AWS Lambda
Amazon Web Services AWS Lambda
Alexa Skills Kit
Amazon Alexa Alexa Skills Kit

Story

Read more

Code

Sample Code for Using Speechcon

JavaScript
    'AMAZON.YesIntent': function() {
        console.log('Preparing to pitch');

        // gather current state of the game
        var inning      = this.attributes["inning"];
        var atBat       = this.attributes["visitorBatter"];
        var batterName  = visitorLineup[atBat-1].lastName
        var pitcherName = homeLineup[8].lastName;

        var audioOutput = pitcherName + " takes the mound in the top of the " + inning + "th inning. ";
            audioOutput = audioOutput + "<break time=\"1s\"/>";
            audioOutput = audioOutput + "Now batting is " + batterName + ". ";
            audioOutput = audioOutput + "<break time=\"1s\"/>";
            audioOutput = audioOutput + "<say-as interpret-as=\"interjection\">batter up</say-as>";
            audioOutput = audioOutput + "<break time=\"1s\"/>";
            audioOutput = audioOutput + "Select a pitch to throw to the batter. ";

        var repromptOutput = "Try saying Fastball, Curve, Slider, or Change-up.";

        // reset the bases
        this.attributes["balls"]   = 0;
        this.attributes["strikes"] = 0;
        this.attributes["runnerOnFirst"]  = false;
        this.attributes["runnerOnSecond"] = false;
        this.attributes["runnerOnThird"]  = false;

        VoiceInsights.track('firstPitch', null, 'middleFastball', (error, response) => {
            this.emit(':ask', audioOutput, repromptOutput);
        });
    },

Credits

Terren Peterson

Terren Peterson

8 projects • 30 followers
Life-long learner who started off with an Electrical Engineering degree, but have been in software and systems engineering my whole career.
Contact

Comments

Add projectSign up / Login