node-red-contrib-tts-ultimate 1.0.42 → 1.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  [![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday)
4
4
 
5
+ <p>
6
+ <b>Version 1.0.43</b> March 2022<br/>
7
+ - Simplified the configuration by auto discover some IP.<br/>
8
+ - FIX: fixed minor glitches.<br/>
9
+ </p>
5
10
  <p>
6
11
  <b>Version 1.0.42</b> March 2022<br/>
7
12
  - FIX: fix purging option that wasn't working if you set to always purge the cached files at startup.<br/>
package/README.md CHANGED
@@ -112,7 +112,7 @@ For Google TTS Engine, you can choose pitch and speed rate of the voice.
112
112
 
113
113
 
114
114
  **Node-Red IP**<br/>
115
- set IP of your node-red machine. Sonos will connect to this address in order to play TTS. You can also write any value you want, for example 127.0.0.1 in this field (**don't leave this field blank in any case**), if you don't want to use Sonos as player. Please see below, the section **TTS-ULTIMATE NODE**, property **Player**.
115
+ set IP of your node-red machine. Write **AUTODISCOVER** to allow the node to auto discover your IP.
116
116
 
117
117
  **Host Port**<br/>
118
118
  Sonos will connect to this port in order to play TTS. Default 1980. Choose a free port. Do not use 1880 or any other port already in use on your computer.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-tts-ultimate",
3
- "version": "1.0.42",
3
+ "version": "1.0.43",
4
4
  "description": "Transforms the text in speech and hear it using Sonos player or generate an audio file to be used with third parties nodes. Works with voices from Amazon, Google (without credentials as well), Microsoft TTS Azure, or your own voice. You can also only create a TTS file to be read by third party nodes. Update of the popular SonosPollyTTS node.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  <script type="text/javascript">
2
+
2
3
  RED.nodes.registerType("ttsultimate-config", {
3
4
  category: 'config',
4
5
  defaults:
@@ -6,7 +7,7 @@
6
7
  name: { value: "TTS Service" },
7
8
  noderedipaddress:
8
9
  {
9
- value: "",
10
+ value: "AUTODISCOVER",
10
11
  required: false,
11
12
  type: "text"
12
13
  },
@@ -32,17 +33,18 @@
32
33
  },
33
34
  oneditprepare: function () {
34
35
  var node = this;
35
-
36
+
36
37
  // 21/03/2020 Check if the node is the absolute first in the flow. In this case, it has no http server instatiaced
37
- $.getJSON('ttsultimateGetEthAddress', (data) => {
38
- $("#pleaseDeploy").hide();
38
+ // $.getJSON('ttsultimateGetEthAddress', (data) => {
39
+ $("#pleaseDeploy").hide();
39
40
  $("#allGUI").show();
40
- }).fail(function (jqxhr) {
41
- $("#pleaseDeploy").show();
42
- $("#allGUI").hide();
43
- });
41
+ // }).fail(function (jqxhr) {
42
+ // $("#pleaseDeploy").show();
43
+ // $("#allGUI").hide();
44
+ // });
44
45
 
45
- if (typeof node.noderedipaddress === "undefined") {
46
+
47
+ if (node.noderedipaddress === undefined) {
46
48
  // Put the default address of the machine
47
49
  $.getJSON('ttsultimateGetEthAddress', (data) => {
48
50
  $("#node-config-input-noderedipaddress").val(data);
@@ -157,7 +159,6 @@
157
159
  <label for="node-config-input-noderedipaddress"><i class="fa fa-globe"></i> Node-Red IP</label>
158
160
  <input type="text" id="node-config-input-noderedipaddress">
159
161
  </div>
160
- <div class="form-tips" style="margin-top: 8px;background-color:lightgrey;text-align:center">Above option: don't leave this field blank in any case. If you don't use Sonos players, set it to 127.0.0.1. See the README on gitHub.</div>
161
162
  <br/>
162
163
 
163
164
  <div class="form-row">
@@ -19,7 +19,11 @@ module.exports = function (RED) {
19
19
  function TTSConfigNode(config) {
20
20
  RED.nodes.createNode(this, config);
21
21
  var node = this;
22
- node.noderedipaddress = typeof config.noderedipaddress === "undefined" ? "" : config.noderedipaddress;
22
+ node.noderedipaddress = config.noderedipaddress;
23
+ if (node.noderedipaddress === undefined || node.noderedipaddress === "AUTODISCOVER") {
24
+ node.noderedipaddress = GetEthAddress();
25
+ RED.log.info('ttsultimate-config ' + node.id + ': Autodiscover current IP ' + node.noderedipaddress);
26
+ }
23
27
  node.whoIsUsingTheServer = ""; // Client node.id using the server, because only a ttsultimate node can use the serve at once.
24
28
  node.ttsservice = config.ttsservice || "googletranslate";
25
29
  node.TTSRootFolderPath = (config.TTSRootFolderPath === undefined || config.TTSRootFolderPath === "") ? path.join(RED.settings.userDir, "sonospollyttsstorage") : path.join(config.TTSRootFolderPath, "sonospollyttsstorage");
@@ -212,6 +216,9 @@ module.exports = function (RED) {
212
216
  // ######################################################
213
217
  // 21/03/2019 Endpoint for retrieving the default IP
214
218
  RED.httpAdmin.get("/ttsultimateGetEthAddress", RED.auth.needsPermission('TTSConfigNode.read'), function (req, res) {
219
+ res.json(GetEthAddress());
220
+ });
221
+ function GetEthAddress() {
215
222
  var oiFaces = oOS.networkInterfaces();
216
223
  var jListInterfaces = [];
217
224
  try {
@@ -229,13 +236,12 @@ module.exports = function (RED) {
229
236
  })
230
237
  } catch (error) { }
231
238
  if (jListInterfaces.length > 0) {
232
- res.json(jListInterfaces[0].address); // Retunr the first usable IP
239
+ return(jListInterfaces[0].address); // Retunr the first usable IP
233
240
  } else {
234
- res.json("NO ETH INTERFACE FOUND");
241
+ return("NO ETH INTERFACE FOUND");
235
242
  }
236
-
237
- });
238
-
243
+ }
244
+
239
245
  // 20/03/2020 in the middle of coronavirus, get the sonos groups
240
246
  RED.httpAdmin.get("/sonosgetAllGroups", RED.auth.needsPermission('TTSConfigNode.read'), function (req, res) {
241
247
  var jListGroups = [];
@@ -202,7 +202,7 @@
202
202
  // 24/12/2020 Check if the node is the absolute first in the flow. In this case, it has no http server instatiaced
203
203
  // !oNodeServer.hasOwnProperty("noderedipaddress") is when the config node exists, but not deployed
204
204
  // oNodeServer.noderedipaddress === "" is when the config node has been deployed, but not configured
205
- if (oNodeServer === null || !oNodeServer.hasOwnProperty("noderedipaddress")) {
205
+ if (oNodeServer === null || oNodeServer === undefined || !oNodeServer.hasOwnProperty("noderedipaddress")) {
206
206
  $("#pleaseDeploy").show();
207
207
  $("#allGUI").hide();
208
208
  } else if (oNodeServer.hasOwnProperty("noderedipaddress") && oNodeServer.noderedipaddress === "") {