echo-sonos
echo-sonos copied to clipboard
Added function for ask Alexa to say phrase in sonos room
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:
- 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.
- 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
@JoacimWall - cool, this has been suggested before. If it works for you, then you might try submitting a pull request with this code in it
There is a default VRSS that doesn't require setup. It uses google voice.
@JoacimWall if you do a pull request. I would recommend making the default volume 30. 60 is quite loud on a play 5.
It also might be fun to have whisper (~vol 10) and shout (~vol 60)
If you don't do a pull request, I would be happy to add this at some point. :)
This work be great if it could be included in the code. :-)
I tried your code a while back @JoacimWall but couldn't get it to work. regardless, do you plan on submitting a pull request? If not, I suppose I'll try again to get this to work and do the PR myself. lmk.