node-red-contrib-sonospollytts
Advanced tools
Comparing version 1.0.16 to 1.0.18
# Node-Red | ||
[![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday) | ||
<p> | ||
<b>Version 1.0.18</b><br/> | ||
- Removed some dependencies to speed up all the things.<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.0.16</b><br/> | ||
@@ -4,0 +11,0 @@ - Changed a little behaviour related to the initial volume setting, when node-red starts or a flow is deployed.<br/> |
{ | ||
"name": "node-red-contrib-sonospollytts", | ||
"version": "1.0.16", | ||
"version": "1.0.18", | ||
"description": "Node-Red TTS with Sonos and Amazon Polly", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/Supergiovane/Node-Red.git" | ||
"url": "https://github.com/Supergiovane/node-red-contrib-sonospollytts.git" | ||
}, | ||
@@ -39,7 +39,4 @@ "keywords": [ | ||
"fs": "0.0.1-security", | ||
"lodash": "^4.17.4", | ||
"mkdirp": "^0.5.1", | ||
"path": "^0.12.7", | ||
"path-exists": "^3.0.0", | ||
"slug": "^0.9.1", | ||
"sonos": ">=1.10.0" | ||
@@ -46,0 +43,0 @@ }, |
# Node-Red SonosPollyTTS | ||
[![NPM version][npm-version-image]][npm-url] | ||
[![NPM downloads per month][npm-downloads-month-image]][npm-url] | ||
[![NPM downloads total][npm-downloads-total-image]][npm-url] | ||
[![MIT License][license-image]][license-url] | ||
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) | ||
[![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday) | ||
<img src='https://github.com/Supergiovane/node-red-contrib-sonospollytts/raw/master/README.png' width="100%"> | ||
@@ -8,3 +15,2 @@ | ||
This node uses <a href="https://aws.amazon.com/polly/">Polly</a> TTS and Sonos api. | ||
Do you want to support this project?<br/><a href="https://www.paypal.me/techtoday/5"><img src="https://www.paypalobjects.com/webstatic/mktg/logo/pp_cc_mark_37x23.jpg"></a> | ||
@@ -38,2 +44,3 @@ ## CHANGELOG | ||
## COPY/PASTE IN YOUR NODE-RED FLOW | ||
```js | ||
@@ -208,1 +215,7 @@ [ | ||
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg | ||
[license-url]: https://github.com/Supergiovane/node-red-contrib-sonospollytts/master/LICENSE | ||
[npm-url]: https://npmjs.org/package/node-red-contrib-sonospollytts | ||
[npm-version-image]: https://img.shields.io/npm/v/node-red-contrib-sonospollytts.svg | ||
[npm-downloads-month-image]: https://img.shields.io/npm/dm/node-red-contrib-sonospollytts.svg | ||
[npm-downloads-total-image]: https://img.shields.io/npm/dt/node-red-contrib-sonospollytts.svg |
@@ -5,3 +5,2 @@ module.exports = function(RED) { | ||
var AWS = require('aws-sdk'); | ||
var slug = require('slug'); | ||
var fs = require('fs'); | ||
@@ -12,4 +11,2 @@ var mkdirp = require('mkdirp'); | ||
var path = require('path'); | ||
var pathExists = require('path-exists'); | ||
var _ = require('lodash'); | ||
var os = require('os'); // Retrieve the local IP | ||
@@ -23,10 +20,23 @@ const sonos = require('sonos'); | ||
slug.charmap['.'] = '_stop_'; | ||
slug.charmap['?'] = '_qm_'; | ||
slug.charmap['!'] = '_em_'; | ||
slug.charmap[','] = '_pause_'; | ||
slug.charmap[':'] = '_colon_'; | ||
slug.charmap[';'] = '_semicolon_'; | ||
slug.charmap['<'] = '_less_'; | ||
slug.charmap['>'] = '_greater_'; | ||
function slug(_text) { | ||
var sRet = _text; | ||
sRet = sRet.toString().replace(/\./g, "_stop_"); | ||
sRet = sRet.toString().replace(/\?/g, "_qm_"); | ||
sRet = sRet.toString().replace(/\!/g, "_em_"); | ||
sRet = sRet.toString().replace(/\,/g, "_pause_"); | ||
sRet = sRet.toString().replace(/\:/g, "_colon_"); | ||
sRet = sRet.toString().replace(/\;/g, "_semicolon_"); | ||
sRet = sRet.toString().replace(/\</g, "_less_"); | ||
sRet = sRet.toString().replace(/\>/g, "_greater_"); | ||
// slug.charmap['.'] = '_stop_'; | ||
// slug.charmap['?'] = '_qm_'; | ||
// slug.charmap['!'] = '_em_'; | ||
// slug.charmap[','] = '_pause_'; | ||
// slug.charmap[':'] = '_colon_'; | ||
// slug.charmap[';'] = '_semicolon_'; | ||
// slug.charmap['<'] = '_less_'; | ||
// slug.charmap['>'] = '_greater_'; | ||
return sRet; | ||
} | ||
@@ -590,3 +600,3 @@ function setupDirectory(aPath) { | ||
// 12/06/2018 Controllo se il payload è un'impostazione del volume | ||
if (_.isString(msg.volume)) { | ||
if (msg.hasOwnProperty("volume")) { | ||
node.sSonosVolume=msg.volume; | ||
@@ -596,3 +606,3 @@ } | ||
// 17/04/2019 Verifico se possso mandare in play l'hailing | ||
if (_.isString(msg.nohailing)) { | ||
if (msg.hasOwnProperty("nohailing")) { | ||
if (msg.nohailing=="1" || msg.nohailing.toLowerCase()=="true") | ||
@@ -610,3 +620,3 @@ { | ||
if(!_.isString(msg.payload)){ | ||
if(!msg.hasOwnProperty("payload")){ | ||
notifyError(node, msg, 'msg.payload must be of type String'); | ||
@@ -847,30 +857,30 @@ return; | ||
// Check if cached | ||
pathExists(filename).then(res => { | ||
if (res) { | ||
// Cached | ||
// Play | ||
PlaySonos(filename,node); | ||
return; | ||
//return node.send([msg, null]); | ||
}; | ||
if (fs.existsSync(filename)){ | ||
node.status({fill: 'green',shape: 'ring',text: 'from cache'}); | ||
RED.log.info('SonosPollyTTS: DEBUG - fromcache : ' + filename); | ||
PlaySonos(filename, node); | ||
return; | ||
} | ||
// pathExists(filename).then(res => { | ||
// if (res) { | ||
// // Cached | ||
// // Play | ||
// PlaySonos(filename, node); | ||
// return; | ||
// //return node.send([msg, null]); | ||
// }; | ||
// Not cached | ||
node.status({ | ||
fill: 'yellow', | ||
shape: 'dot', | ||
text: 'requesting'}); | ||
node.status({fill: 'yellow',shape: 'dot',text: 'asking online'}); | ||
var params = { | ||
OutputFormat: outputFormat, | ||
SampleRate: '22050', | ||
Text: msg, | ||
TextType: node.ssml ? 'ssml' : 'text', | ||
VoiceId: node.iVoice | ||
}; | ||
var params = { | ||
OutputFormat: outputFormat, | ||
SampleRate: '22050', | ||
Text: msg, | ||
TextType: node.ssml ? 'ssml' : 'text', | ||
VoiceId: node.iVoice | ||
}; | ||
synthesizeSpeech([polly, params]) | ||
.then(data => { | ||
return [filename, data.AudioStream]; | ||
}).then(cacheSpeech).then(function() { | ||
synthesizeSpeech([polly, params]).then(data => { return [filename, data.AudioStream]; }).then(cacheSpeech).then(function () { | ||
// Success | ||
@@ -881,9 +891,8 @@ node.status({}); | ||
// Play | ||
PlaySonos(filename,node); | ||
PlaySonos(filename, node); | ||
}).catch(error => { | ||
notifyError(node, filename, error); | ||
}); | ||
}); | ||
}).catch(error => { notifyError(node, filename, error); }); | ||
//}); | ||
} | ||
@@ -897,6 +906,5 @@ | ||
} | ||
resolve(data); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
@@ -940,3 +948,3 @@ | ||
function notifyError(node, msg, err) { | ||
var errorMessage = _.isString(err) ? err : err.message; | ||
var errorMessage = err.message; | ||
// Output error to console | ||
@@ -943,0 +951,0 @@ //RED.log.error('SonosPollyTTS synthesizeSpeech: ' + errorMessage); |
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
354434
6
10
888
218
1
- Removedlodash@^4.17.4
- Removedpath-exists@^3.0.0
- Removedslug@^0.9.1
- Removedlodash@4.17.21(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedslug@0.9.4(transitive)
- Removedunicode@14.0.0(transitive)