Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-sonospollytts

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-sonospollytts - npm Package Compare versions

Comparing version 1.1.36 to 1.1.37

4

CHANGELOG.md

@@ -6,2 +6,6 @@ ![Sample Node](img/logo.png)

<p>
<b>Version 1.1.37</b> November 2020<br/>
- NEW: resume music queue after TTS speech. Once finished playing the voice speak, the music queue restart at the exact position, at the exact track time.<br/>
</p>
<p>
<b>Version 1.1.36</b> November 2020<br/>

@@ -8,0 +12,0 @@ - Whenever node-red is restarted or you make a deploy while Sonos is playing music, the node won't stop Sonos players anymore.<br/>

2

package.json
{
"name": "node-red-contrib-sonospollytts",
"version": "1.1.36",
"version": "1.1.37",
"description": "Node-Red TTS with Sonos and Amazon Polly or with your own local mp3 announcement files. Transforms the text in speech and hear it using Sonos player. Can work OFFLINE as well! This node is specific for security alarm announcement, doorbell, weather annoucement etc.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -28,5 +28,6 @@ # Node-Red SonosPollyTTS

## DESCRIPTION
This node transforms a text into a speech audio. It supports many voice languages. You can hear the voice through Sonos.
This node transforms a text into a speech audio. It supports many voice languages. You can hear the voice through Sonos.<br/>
This node uses <a href="https://aws.amazon.com/polly/">Polly</a> TTS and Sonos api. It supports PLAYERS GROUPING.<br/>
You can use it with **your own audio file** as well and it can be used **totally offline** even without the use of TTS, without internet connection.
You can use it with **your own audio file** as well and it can be used **totally offline** even without the use of TTS, without internet connection.<br/>
If a previously music queue was playing, once the speech has finished, the node will resume the music queue at the exact track, at the exact seek time.

@@ -46,2 +47,3 @@ [![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday).

* Works with node-red in HTTP and in HTTPS mode.
* Automatic resume of music queue.
<br/><br/>

@@ -52,2 +54,6 @@ > IF YOU RUN NODE-RED BEHIND DOCKER OR SOMETHING ELSE, BE AWARE: <br/>

<br/>
### HOW-TO in Deutsch: for german users, there is a very helpful how-to, where you can learn how to use the node and how to register to Amazon AWS Polly as well: here: https://technikkram.net/blog/2020/09/26/sonos-sprachausgabe-mit-raspberry-pi-node-red-und-amazon-polly-fuer-homematic-oder-knx-systeme
<br/><br/><br/><br/>

@@ -54,0 +60,0 @@

@@ -10,4 +10,4 @@ module.exports = function (RED) {

const sonos = require('sonos');
// AWS.config.update({

@@ -51,5 +51,5 @@ // region: 'us-east-1'

// Node Register

@@ -80,2 +80,3 @@ function PollyNode(config) {

node.sNoderedURL = "";
node.currMusicTrack = null; // 04/12/2020 Current position of the currently playing music in the queue
if (typeof node.server !== "undefined" && node.server !== null) {

@@ -134,4 +135,4 @@ node.sNoderedURL = node.server.sNoderedURL || "";

// Set ssml

@@ -736,8 +737,4 @@ node.ssml = config.ssml;

node.curTrack;
node.on('input', function (msg) {
// 12/06/2018 Controllo se il payload è un'impostazione del volume
if (msg.hasOwnProperty("volume")) {
node.sSonosVolume = msg.volume;
}

@@ -749,2 +746,47 @@ if (!msg.hasOwnProperty("payload")) {

// 04/12/2020 Handle music queue
//#region "HANDLE MUSIC QUEUE"
node.SonosClient.getCurrentState().then(state => {
//console.log("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + node.msg.completed)
// A music queue is playing and no TTS is speaking?
if (state.toString().toLowerCase() === "playing" && node.msg.completed === true) {
//console.log("AAaaaaAAaaaaAAaaaaAAaaaaAAaaaaAAaaaaAAaaaa")
// Get current track
node.SonosClient.currentTrack().then(track => {
//console.log("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")
node.currMusicTrack = track;// .queuePosition || 1; // Get the current track in the queue.
node.SonosClient.getVolume().then(volume => {
//console.log("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC")
node.currMusicTrack.currentVolume = volume; // Get the current volume
console.log("VOLUMA " + volume);
continueProcessingInputMSG();
}).catch(err => {
node.currMusicTrack = null;
console.log('SonospollyTTS: getVolume Error occurred %j', err);
continueProcessingInputMSG();
})
}).catch(err => {
node.currMusicTrack = null;
console.log('SonospollyTTS: Error currentTrackoccurred %j', err);
continueProcessingInputMSG();
})
} else {
node.currMusicTrack = null;
continueProcessingInputMSG();
};
}).catch(err => {
node.currMusicTrack = null;
console.log('SonospollyTTS: getCurrentState: Error occurred %j', err);
continueProcessingInputMSG();
})
//#endregion
// Continue processing the input command
function continueProcessingInputMSG() {
// 12/06/2018 Controllo se il payload è un'impostazione del volume
if (msg.hasOwnProperty("volume")) {
node.sSonosVolume = msg.volume;
}
try {

@@ -791,2 +833,3 @@ node.setNodeStatus({

// If the queue is empty and if i can play the Haniling, add the hailing file first

@@ -801,2 +844,4 @@ if (node.aMessageQueue.length == 0 && node.sonoshailing !== "0") {

node.setNodeStatus({ fill: 'yellow', shape: 'dot', text: 'Queued ' + msg.payload });
}

@@ -808,3 +853,3 @@ });

clearTimeout(node.oTimerSonosConnectionCheck);
// 10/11/2020 Avoit stopping sonos, if someone is using it for, for example, playing music.

@@ -814,3 +859,3 @@ // node.SonosClient.stop().then(() => {

// });
node.msg.completed = true;

@@ -821,3 +866,3 @@ node.send(node.msg);

done();
});

@@ -985,3 +1030,3 @@

try {
if (node.msg.completed == false && node.sSonosPlayState == "stopped") {
if (node.msg.completed === false && node.sSonosPlayState == "stopped") {
node.msg.completed = true;

@@ -991,9 +1036,42 @@ node.ungroupSpeakers(); // 20/03/2020 Ungroup Speakers

node.setNodeStatus({ fill: "green", shape: "ring", text: "" + node.sSonosPlayState });
// Resume the music queue at exact position and seek to exact time
if (node.currMusicTrack !== null) {
node.SonosClient.selectQueue().then(success => {
node.SonosClient.selectTrack(node.currMusicTrack.queuePosition).then(success => {
node.SonosClient.seek(node.currMusicTrack.position).then(success => {
node.SonosClient.setVolume(node.currMusicTrack.currentVolume).then(success => {
node.SonosClient.play().then(success => {
node.currMusicTrack = null;
}).catch(err => {
node.currMusicTrack = null;
console.log('Error occurred PLAY %j', err)
})
}).catch(err => {
node.currMusicTrack = null;
console.log('Error occurred setVolume %j', err)
})
}).catch(err => {
node.currMusicTrack = null;
console.log('Error occurred SEEK %j', err)
})
}).catch(err => {
node.currMusicTrack = null;
console.log('Error occurred SELECTTRACK %j', err)
})
}).catch(err => { console.log('Error occurred %j', err) })
}
}
} catch (error) { }
// Resume Queue
}
}
// Reas the text via Polly
// Read the text via Polly
function Leggi(msg) {

@@ -1181,6 +1259,2 @@

}

@@ -1187,0 +1261,0 @@ RED.nodes.registerType('sonospollytts', PollyNode);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc