Skip to content

Added function for ask Alexa to say phrase in sonos room #95

Open
@JoacimWall

Description

@JoacimWall

Hi i used the node-sonos-http-api to say to my kids that the dinner is ready throw sonos. So i added support for this so Alex can do it for me by changing some of the code.

I don't know how this work if i just can add code/shelve it and someone validate it. When this is my first try to code som js(.net programmer) so I just add it inside this topic and så can anyone use it if the want and if someone of the contributors add it to the repo if the think it's a good ide.

//Joacim Wall

for this to work you need to do the following:

  1. set upp node-sonos-http-api to use VoiceRSS more info on https://github.com/jishi/node-sonos-http-api try so int work throw your browser.
  2. in your Lambda service
    2.1 Intent Schema add
    {
    "intent": "SayIntent",
    "slots": [
    {
    "name": "Preset",
    "type": "PRESETS"
    },
    {
    "name": "Room",
    "type": "ROOMS"
    }
    ]
    },
    {
    "intent": "SayallIntent",
    "slots": [
    {
    "name": "Preset",
    "type": "PRESETS"
    },
    {
    "name": "Room",
    "type": "ROOMS"
    }
    ]
    },

2.2 Sample Utterances add
SayIntent say {Preset}
SayIntent say {Preset} in {Room}
SayIntent say {Preset} in the {Room}

SayallIntent sayall {Preset}
SayallIntent sayall {Preset} in {Room}
SayallIntent sayall {Preset} in the {Room}

2.3 In index.js add
var languageSay = (options.languageSay != undefined)?options.languageSay:'en-us';
var volumeSay = (options.volumeSay != undefined)?options.volumeSay:'50';

SayIntent: function (intent, session, response) {
 console.log("SayIntent received");
 loadCurrentRoomAndService('DefaultEcho', intent.slots.Room.value, function(room, service) {
 options.path = '/' + encodeURIComponent(room) + '/say/' + encodeURIComponent(intent.slots.Preset.value) + '/' + languageSay.toLowerCase() + '/' + volumeSay.toLowerCase();
 httpreq(options, function(error) {
 genericResponse(error, response, "say " + ntent.slots.Preset.value);
 } );
 });
 },
 
SayallIntent: function (intent, session, response) {
 console.log("SayallIntent received");
 options.path = '/sayall/' + encodeURIComponent(intent.slots.Preset.value) + '/' + languageSay.toLowerCase() + '/' + volumeSay.toLowerCase();
 httpreq(options, function(error) {
 genericResponse(error, response, "say " + ntent.slots.Preset.value);
 } );
 },


2.4 in options.js add
languageSay: 'en-us', //uses when you use the say/sayall command on node-sonos-http-api
volumeSay: '60'//uses when you use the say/sayall command on node-sonos-http-api

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions