node-red-contrib-sonospollytts
Advanced tools
Comparing version 1.1.10 to 1.1.11
@@ -8,2 +8,7 @@ ![Sample Node](img/logo.png) | ||
<p> | ||
<b>Version 1.1.11</b><br/> | ||
- NEW: Added DELETE ALL FILES, to allow you to delete all custom files at once.<br/> | ||
- Added OwnFile samples audio and sample code in README<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.1.10</b><br/> | ||
@@ -10,0 +15,0 @@ - Optimized UI for new OwnFile nodes<br/> |
{ | ||
"name": "node-red-contrib-sonospollytts", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"description": "Node-Red TTS with Sonos and Amazon Polly or with your own local mp3 announcement files. This node is specific for security alarm announcement, zone announcement, doorbell, weather annoucement etc.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
252
README.md
@@ -15,68 +15,4 @@ # 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 uses <a href="https://aws.amazon.com/polly/">Polly</a> TTS and Sonos api. | ||
<details><summary> --->> VIEW SAMPLE CODE <<--- </summary> | ||
[![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday) and <a href="http://eepurl.com/gJm095" target="_blank">subscribe to my channel</a> for the latest news, if you enjoy my node. | ||
## CHANGELOG | ||
* See <a href="https://github.com/Supergiovane/node-red-contrib-sonospollytts/blob/master/CHANGELOG.md">here the changelog</a> | ||
## FEATURES | ||
* Works with node-red in HTTP and in HTTPS mode. | ||
* TTS queues handling. If you send multiple payloads to the node, it'll handle it in his own queue. | ||
* TTS caching. Amazon AWS charges you if you use Polly for a very high rate of text to speech request. The node caches the TTS, so if you requests the same TTS the second time, the node will take it from the cache instead of asking to the Amazon Polly service. | ||
* Send a simple payload with the text you want to speech out. For example <code>node.send({payload:"Hello there!"});</code>. | ||
<br/><br/><br/><br/> | ||
# SONOSPOLLYTTS CONFIGURATION | ||
**Polly Config**<br/> | ||
Create a config with your AWS credentials. If you put incorrect credentials, you'll see this error in the node-red's debug window: *"The security token included in the request is invalid."* | ||
**Polly Voice**<br/> | ||
Select your preferred voice | ||
**Sonos IP** <br/> | ||
Insert your sonos's IP (If your Sonos device doesn't allow you to set a fixed IP, you need to reserve an IP using the DHCP Reservation function of your router/firewall's DHCP Server) | ||
**Sonos Volume** <br/> | ||
set the preferred TTS volume, from "0" to "100" (can be overridden by passing <code>msg.volume="40";</code> to the node) | ||
**Sonos Hailing**<br/> | ||
before the first TTS message of the message queues, Sonos will play an "hailing" sound. You can select the hailing or totally disable it. | ||
**Node-Red IP**<br/> | ||
set IP of your node-red machine | ||
**Host Port**<br/> | ||
normally 1980. This is the IP of your machine, running node-red | ||
**TTS path**<br/> | ||
you can change the temp folder for storing cached TTS files. Default is "tmp". This is valid only if you select to purge the cache folder at each deploy or restart of node-red (see the next option below) | ||
**TTS Cache** | ||
<br/> | ||
Purge and delete the TTS cache folder at deploy or restart(default): on each deploy or node-red restart, delete all tts files in the cache. This is useful not to run out of disk space, in case you've a lot of TTS speech files.<br/> | ||
Leave the TTS cache folder untouched (not suggested if you have less disk space): don't delete any tts file. Useful if you wish to keep the tts files, even in case of internet outages. | ||
### INPUT MESSAGES TO THE NODE | ||
* <code>msg.volume</code> set the volume (values between "0" and "100" with quotes) | ||
* <code>msg.nohailing</code> temporarely doesn't play the Hailing sound prior to the message (values "true" or "1" with quotes) | ||
* <code>msg.payload</code> the text to be spoken (for example msg.payload = "Hello World!";). You can also play an mp3 stored on an http server, by passing the URL to the payload ( <code>msg.payload = "http://www.myserver.com/alarm.mp3"</code>) | ||
*Example of using http mp3 in a function node* | ||
```js | ||
node.send({payload:"http://192.125.22.44/intruderalarm.mp3"}; | ||
node.send({payload:"Warning. Intruder in the dinning room."}; | ||
``` | ||
### OUTPUT MESSAGES FROM THE NODE | ||
* <code>msg.completed</code> <b>true</b> when the node has finished playing, <b>false</b> if the node is playing | ||
* <code>msg.connectionerror</code> <b>true</b> when the node cannot connect to the Sonos device, <b>false</b> if the connection is restored.<br/> | ||
<details><summary>View code</summary> | ||
> Adjust the nodes according to your setup | ||
@@ -253,2 +189,71 @@ | ||
<br/> | ||
<br/> | ||
## DESCRIPTION | ||
This node transforms a text into a speech audio. It supports many voice languages. You can hear the voice through Sonos. | ||
This node uses <a href="https://aws.amazon.com/polly/">Polly</a> TTS and Sonos api. | ||
[![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday) and <a href="http://eepurl.com/gJm095" target="_blank">subscribe to my channel</a> for the latest news, if you enjoy my node. | ||
## CHANGELOG | ||
* See <a href="https://github.com/Supergiovane/node-red-contrib-sonospollytts/blob/master/CHANGELOG.md">here the changelog</a> | ||
## FEATURES | ||
* Works with node-red in HTTP and in HTTPS mode. | ||
* TTS queues handling. If you send multiple payloads to the node, it'll handle it in his own queue. | ||
* TTS caching. Amazon AWS charges you if you use Polly for a very high rate of text to speech request. The node caches the TTS, so if you requests the same TTS the second time, the node will take it from the cache instead of asking to the Amazon Polly service. | ||
* Send a simple payload with the text you want to speech out. For example <code>node.send({payload:"Hello there!"});</code>. | ||
<br/><br/><br/><br/> | ||
# SONOSPOLLYTTS CONFIGURATION | ||
**Polly Config**<br/> | ||
Create a config with your AWS credentials. If you put incorrect credentials, you'll see this error in the node-red's debug window: *"The security token included in the request is invalid."* | ||
**Polly Voice**<br/> | ||
Select your preferred voice | ||
**Sonos IP** <br/> | ||
Insert your sonos's IP (If your Sonos device doesn't allow you to set a fixed IP, you need to reserve an IP using the DHCP Reservation function of your router/firewall's DHCP Server) | ||
**Sonos Volume** <br/> | ||
set the preferred TTS volume, from "0" to "100" (can be overridden by passing <code>msg.volume="40";</code> to the node) | ||
**Sonos Hailing**<br/> | ||
before the first TTS message of the message queues, Sonos will play an "hailing" sound. You can select the hailing or totally disable it. | ||
**Node-Red IP**<br/> | ||
set IP of your node-red machine | ||
**Host Port**<br/> | ||
normally 1980. This is the IP of your machine, running node-red | ||
**TTS path**<br/> | ||
you can change the temp folder for storing cached TTS files. Default is "tmp". This is valid only if you select to purge the cache folder at each deploy or restart of node-red (see the next option below) | ||
**TTS Cache** | ||
<br/> | ||
Purge and delete the TTS cache folder at deploy or restart(default): on each deploy or node-red restart, delete all tts files in the cache. This is useful not to run out of disk space, in case you've a lot of TTS speech files.<br/> | ||
Leave the TTS cache folder untouched (not suggested if you have less disk space): don't delete any tts file. Useful if you wish to keep the tts files, even in case of internet outages. | ||
### INPUT MESSAGES TO THE NODE | ||
* <code>msg.volume</code> set the volume (values between "0" and "100" with quotes) | ||
* <code>msg.nohailing</code> temporarely doesn't play the Hailing sound prior to the message (values "true" or "1" with quotes) | ||
* <code>msg.payload</code> the text to be spoken (for example msg.payload = "Hello World!";). You can also play an mp3 stored on an http server, by passing the URL to the payload ( <code>msg.payload = "http://www.myserver.com/alarm.mp3"</code>) | ||
*Example of using http mp3 in a function node* | ||
```js | ||
node.send({payload:"http://192.125.22.44/intruderalarm.mp3"}; | ||
node.send({payload:"Warning. Intruder in the dinning room."}; | ||
``` | ||
### OUTPUT MESSAGES FROM THE NODE | ||
* <code>msg.completed</code> <b>true</b> when the node has finished playing, <b>false</b> if the node is playing | ||
* <code>msg.connectionerror</code> <b>true</b> when the node cannot connect to the Sonos device, <b>false</b> if the connection is restored.<br/> | ||
<br/><br/><br/> | ||
@@ -260,2 +265,119 @@ | ||
<details><summary> --->> VIEW SAMPLE CODE <<--- </summary> | ||
> Adjust the nodes according to your setup | ||
```js | ||
[ | ||
{ | ||
"id": "9389863f.c9e44", | ||
"type": "sonospollytts", | ||
"z": "2e6a2c30.383f64", | ||
"name": "", | ||
"purgediratrestart": "leave", | ||
"voice": "51", | ||
"ssml": false, | ||
"dir": "/tmp", | ||
"sonosipaddress": "192.168.1.109", | ||
"sonosvolume": "20", | ||
"sonoshailing": "0", | ||
"noderedipaddress": "192.168.1.146", | ||
"noderedport": "1980", | ||
"config": "8194024b.fa7", | ||
"x": 680, | ||
"y": 340, | ||
"wires": [ | ||
[] | ||
] | ||
}, | ||
{ | ||
"id": "90a05585.bc514", | ||
"type": "ownfile", | ||
"z": "2e6a2c30.383f64", | ||
"name": "", | ||
"selectedFile": "OwnFile_Living room window open.mp3", | ||
"x": 350, | ||
"y": 340, | ||
"wires": [ | ||
[ | ||
"9389863f.c9e44" | ||
] | ||
] | ||
}, | ||
{ | ||
"id": "d416ac1c.e5c8b", | ||
"type": "inject", | ||
"z": "2e6a2c30.383f64", | ||
"name": "", | ||
"topic": "", | ||
"payload": "true", | ||
"payloadType": "bool", | ||
"repeat": "", | ||
"crontab": "", | ||
"once": false, | ||
"onceDelay": 0.1, | ||
"x": 150, | ||
"y": 340, | ||
"wires": [ | ||
[ | ||
"90a05585.bc514" | ||
] | ||
] | ||
}, | ||
{ | ||
"id": "3b08c36d.aba304", | ||
"type": "comment", | ||
"z": "2e6a2c30.383f64", | ||
"name": "You can upload your own voice messages and use it with SonosPollyTTS", | ||
"info": "", | ||
"x": 340, | ||
"y": 300, | ||
"wires": [] | ||
}, | ||
{ | ||
"id": "b6061743.7f9ce", | ||
"type": "ownfile", | ||
"z": "2e6a2c30.383f64", | ||
"name": "", | ||
"selectedFile": "OwnFile_Tur geoeffnet.mp3", | ||
"x": 310, | ||
"y": 400, | ||
"wires": [ | ||
[ | ||
"9389863f.c9e44" | ||
] | ||
] | ||
}, | ||
{ | ||
"id": "6cac28fd.4088a8", | ||
"type": "inject", | ||
"z": "2e6a2c30.383f64", | ||
"name": "", | ||
"topic": "", | ||
"payload": "true", | ||
"payloadType": "bool", | ||
"repeat": "", | ||
"crontab": "", | ||
"once": false, | ||
"onceDelay": 0.1, | ||
"x": 150, | ||
"y": 400, | ||
"wires": [ | ||
[ | ||
"b6061743.7f9ce" | ||
] | ||
] | ||
}, | ||
{ | ||
"id": "8194024b.fa7", | ||
"type": "sonospollytts-config", | ||
"z": "", | ||
"name": "asd" | ||
} | ||
] | ||
``` | ||
</details> | ||
This node allow you to upload your custom message and play it via SonosPollyTTS without the need of an internet connection. You can use it, for example, with your alarm panel, to annuce a zone breach, a doorbell or so. | ||
@@ -262,0 +384,0 @@ |
@@ -24,10 +24,32 @@ | ||
// 27/02/2020 Delete OwnFile_ | ||
RED.httpAdmin.get("/deleteOwnFile", RED.auth.needsPermission('ownfile.read'), function (req, res) { | ||
try { | ||
var newPath = __dirname + "/ttspermanentfiles/" + req.query.FileName; | ||
fs.unlinkSync(newPath) | ||
} catch(err) { | ||
} | ||
res.json({ status: 220 }); | ||
// 27/02/2020 Delete OwnFile_ | ||
RED.httpAdmin.get("/deleteOwnFile", RED.auth.needsPermission('ownfile.read'), function (req, res) { | ||
try { | ||
if (req.query.FileName == "DELETEallFiles") { | ||
// Delete all OwnFiles_ | ||
try { | ||
fs.readdir(__dirname + "/ttspermanentfiles/", (err, files) => { | ||
files.forEach(function (file) { | ||
if (file.indexOf("OwnFile_") !== -1) { | ||
RED.log.warn("SonospollyTTS: Deleted file " + __dirname + "/ttspermanentfiles/" + file); | ||
fs.unlink(__dirname + "/ttspermanentfiles/" + file), err => {}; | ||
} | ||
}); | ||
}); | ||
} catch (error) { | ||
} | ||
} else { | ||
// Delete only one file | ||
try { | ||
var newPath = __dirname + "/ttspermanentfiles/" + req.query.FileName; | ||
fs.unlinkSync(newPath) | ||
} catch (error) { | ||
} | ||
} | ||
} catch (err) { | ||
} | ||
res.json({ status: 220 }); | ||
}); | ||
@@ -60,3 +82,3 @@ | ||
} else { | ||
if (msg.hasOwnProperty("selectedFile")) msg.payload = "OwnFile_" + msg.selectedFile.replace(".mp3","") + ".mp3"; | ||
if (msg.hasOwnProperty("selectedFile")) msg.payload = "OwnFile_" + msg.selectedFile.replace(".mp3", "") + ".mp3"; | ||
node.send(msg); | ||
@@ -63,0 +85,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
625884
18
1085
400
7