node-red-contrib-tts-ultimate 1.0.41 → 1.0.42
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
|
[](https://www.paypal.me/techtoday)
|
|
4
4
|
|
|
5
|
+
<p>
|
|
6
|
+
<b>Version 1.0.42</b> March 2022<br/>
|
|
7
|
+
- FIX: fix purging option that wasn't working if you set to always purge the cached files at startup.<br/>
|
|
8
|
+
- FIX: invalid code in some sync functions.<br/>
|
|
9
|
+
</p>
|
|
5
10
|
<p>
|
|
6
11
|
<b>Version 1.0.41</b> March 2022<br/>
|
|
7
12
|
- NEW: for Polly TTS, you can choose between neural and standard engine.<br/>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-tts-ultimate",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
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": {
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
// The only way is to wait some time, then refresh
|
|
84
|
-
setTimeout(function () {
|
|
84
|
+
let t = setTimeout(function () {
|
|
85
85
|
node.refreshListaFiles().then((success, error) => {
|
|
86
86
|
$("#ownFileUpload").val("");// Otherwise will not re-upload a file with the same name
|
|
87
87
|
$("#node-input-selectedFile").val("OwnFile_" + file.name);
|
|
@@ -538,22 +538,20 @@ module.exports = function (RED) {
|
|
|
538
538
|
if (node.purgediratrestart === "purge") {
|
|
539
539
|
// Delete all files, that are'nt OwnFiles_
|
|
540
540
|
try {
|
|
541
|
-
fs.readdirSync(path.join(node.TTSRootFolderPath, "ttsfiles")
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
541
|
+
let files = fs.readdirSync(path.join(node.TTSRootFolderPath, "ttsfiles"));
|
|
542
|
+
try {
|
|
543
|
+
if (files.length > 0) {
|
|
544
|
+
files.forEach(function (file) {
|
|
545
|
+
RED.log.info("ttsultimate-config " + node.id + ": Deleted TTS file " + path.join(node.TTSRootFolderPath, "ttsfiles", file));
|
|
546
|
+
try {
|
|
547
|
+
fs.unlinkSync(path.join(node.TTSRootFolderPath, "ttsfiles", file));
|
|
548
|
+
} catch (error) {
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
};
|
|
552
|
+
} catch (error) { }
|
|
553
553
|
|
|
554
|
-
}
|
|
555
554
|
|
|
556
|
-
});
|
|
557
555
|
} catch (error) { }
|
|
558
556
|
};
|
|
559
557
|
|
|
@@ -572,13 +570,13 @@ module.exports = function (RED) {
|
|
|
572
570
|
var query = url_parts.query;
|
|
573
571
|
|
|
574
572
|
res.setHeader('Content-Disposition', 'attachment; filename=tts.mp3')
|
|
575
|
-
if (fs.existsSync(query.f)) {
|
|
573
|
+
if (fs.existsSync(query.f.toString())) {
|
|
576
574
|
// 26/01/2021 security check
|
|
577
575
|
// File should be something like mydocs/.node-red/sonospollyttsstorage/ttsfiles/Hello_de-DE.mp3
|
|
578
|
-
if (path.extname(query.f) === ".mp3" && path.dirname(path.dirname(query.f)).endsWith("sonospollyttsstorage")) {
|
|
579
|
-
var readStream = fs.createReadStream(query.f);
|
|
576
|
+
if (path.extname(query.f.toString()) === ".mp3" && path.dirname(path.dirname(query.f.toString())).endsWith("sonospollyttsstorage")) {
|
|
577
|
+
var readStream = fs.createReadStream(query.f.toString());
|
|
580
578
|
readStream.on("error", function (error) {
|
|
581
|
-
RED.log.error("ttsultimate-config " + node.id + ": Playsonos error opening stream : " + query.f + ' : ' + error);
|
|
579
|
+
RED.log.error("ttsultimate-config " + node.id + ": Playsonos error opening stream : " + query.f.toString() + ' : ' + error);
|
|
582
580
|
res.end();
|
|
583
581
|
return;
|
|
584
582
|
});
|
|
@@ -637,7 +635,7 @@ module.exports = function (RED) {
|
|
|
637
635
|
} catch (error) {
|
|
638
636
|
|
|
639
637
|
}
|
|
640
|
-
setTimeout(function () {
|
|
638
|
+
let t = setTimeout(function () {
|
|
641
639
|
// Wait some time to allow time to do promises.
|
|
642
640
|
done();
|
|
643
641
|
}, 500);
|
|
@@ -336,7 +336,7 @@
|
|
|
336
336
|
}
|
|
337
337
|
// Refresh the combo
|
|
338
338
|
// The only way is to wait some time, then refresh
|
|
339
|
-
setTimeout(function () {
|
|
339
|
+
let t = setTimeout(function () {
|
|
340
340
|
node.refreshHailingList().then((success, error) => {
|
|
341
341
|
$("#ownFileUpload").val("");// Otherwise will not re-upload a file with the same name
|
|
342
342
|
$("#node-input-sonoshailing").val("Hailing_" + file.name);
|
|
@@ -52,7 +52,7 @@ module.exports = function (RED) {
|
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
node.ssml = config.ssml;
|
|
55
|
-
node.oTimerSonosConnectionCheck;
|
|
55
|
+
node.oTimerSonosConnectionCheck = null;
|
|
56
56
|
node.sSonosIPAddress = "";
|
|
57
57
|
node.sonosCoordinatorGroupName = "";
|
|
58
58
|
node.sonoshailing = "0"; // Hailing file
|
|
@@ -78,6 +78,7 @@ module.exports = function (RED) {
|
|
|
78
78
|
node.unmuteIfMuted = config.unmuteIfMuted === undefined ? false : config.unmuteIfMuted; // 21/10/2021 Unmute if previiously muted.
|
|
79
79
|
node.sonosCoordinatorIsPreviouslyMuted = false;
|
|
80
80
|
node.passThroughMessage = {};
|
|
81
|
+
node.bTimeOutPlay = false;
|
|
81
82
|
|
|
82
83
|
if (typeof node.server !== "undefined" && node.server !== null) {
|
|
83
84
|
node.sNoderedURL = node.server.sNoderedURL || "";
|
|
@@ -120,7 +121,7 @@ module.exports = function (RED) {
|
|
|
120
121
|
return new Promise((resolve, reject) => {
|
|
121
122
|
node.SonosClient.play(_toPlay).then(result => {
|
|
122
123
|
if (iWaitAfterSync > 2000) console.log("PLAYSYNC")
|
|
123
|
-
setTimeout(() => {
|
|
124
|
+
let t = setTimeout(() => {
|
|
124
125
|
resolve(true);
|
|
125
126
|
}, iWaitAfterSync);
|
|
126
127
|
}).catch(err => {
|
|
@@ -135,7 +136,7 @@ module.exports = function (RED) {
|
|
|
135
136
|
return new Promise((resolve, reject) => {
|
|
136
137
|
node.SonosClient.seek(_Position).then(result => {
|
|
137
138
|
if (iWaitAfterSync > 2000) console.log("SEEKSync", _Position)
|
|
138
|
-
setTimeout(() => {
|
|
139
|
+
let t = setTimeout(() => {
|
|
139
140
|
resolve(true);
|
|
140
141
|
}, iWaitAfterSync);
|
|
141
142
|
}).catch(err => {
|
|
@@ -154,7 +155,7 @@ module.exports = function (RED) {
|
|
|
154
155
|
STOPSync(); // The SetQueue automatically starts playing, so i need to stop it now!
|
|
155
156
|
} catch (error) {
|
|
156
157
|
}
|
|
157
|
-
setTimeout(() => {
|
|
158
|
+
let t = setTimeout(() => {
|
|
158
159
|
resolve(true);
|
|
159
160
|
}, iWaitAfterSync);
|
|
160
161
|
}).catch(err => {
|
|
@@ -169,7 +170,7 @@ module.exports = function (RED) {
|
|
|
169
170
|
return new Promise((resolve, reject) => {
|
|
170
171
|
node.SonosClient.selectTrack(_queuePositiom).then(result => {
|
|
171
172
|
if (iWaitAfterSync > 2000) console.log("SELECTTRACKSync", _queuePositiom)
|
|
172
|
-
setTimeout(() => {
|
|
173
|
+
let t = setTimeout(() => {
|
|
173
174
|
resolve(true);
|
|
174
175
|
}, iWaitAfterSync);
|
|
175
176
|
}).catch(err => {
|
|
@@ -184,7 +185,7 @@ module.exports = function (RED) {
|
|
|
184
185
|
return new Promise((resolve, reject) => {
|
|
185
186
|
node.SonosClient.stop().then(result => {
|
|
186
187
|
if (iWaitAfterSync > 2000) console.log("STOPSync")
|
|
187
|
-
setTimeout(() => {
|
|
188
|
+
let t = setTimeout(() => {
|
|
188
189
|
resolve(true);
|
|
189
190
|
}, iWaitAfterSync);
|
|
190
191
|
}).catch(err => {
|
|
@@ -509,7 +510,7 @@ module.exports = function (RED) {
|
|
|
509
510
|
}
|
|
510
511
|
}
|
|
511
512
|
}
|
|
512
|
-
setTimeout(() => { return true; }, 5000); // Wait some seconds
|
|
513
|
+
let t = setTimeout(() => { return true; }, 5000); // Wait some seconds
|
|
513
514
|
};
|
|
514
515
|
|
|
515
516
|
// Handle the queue
|
|
@@ -619,13 +620,14 @@ module.exports = function (RED) {
|
|
|
619
620
|
data = await synthesizeSpeechMicrosoftAzureTTS(node.server.microsoftAzureTTS, params);
|
|
620
621
|
}
|
|
621
622
|
// Save the downloaded file into the cache
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
}
|
|
623
|
+
try {
|
|
624
|
+
fs.writeFileSync(sFileToBePlayed, data);
|
|
625
|
+
} catch (error) {
|
|
626
|
+
RED.log.error("ttsultimate: node id: " + node.id + " Unable to save the file " + error.message);
|
|
627
|
+
node.setNodeStatus({ fill: "red", shape: "ring", text: "Unable to save the file " + sFileToBePlayed + " " + error.message });
|
|
628
|
+
throw (error);
|
|
629
|
+
}
|
|
630
|
+
|
|
629
631
|
} catch (error) {
|
|
630
632
|
RED.log.error("ttsultimate: node id: " + node.id + " Error Downloading TTS: " + error.message + ". THE TTS SERVICE MAY BE DOWN.");
|
|
631
633
|
node.setNodeStatus({ fill: 'red', shape: 'ring', text: 'Error Downloading TTS:' + error.message });
|
|
@@ -781,7 +783,7 @@ module.exports = function (RED) {
|
|
|
781
783
|
}
|
|
782
784
|
|
|
783
785
|
// Signal end playing
|
|
784
|
-
setTimeout(() => {
|
|
786
|
+
let t = setTimeout(() => {
|
|
785
787
|
node.msg.completed = true;
|
|
786
788
|
node.currentMSGbeingSpoken = {};
|
|
787
789
|
node.send([{ passThroughMessage: node.passThroughMessage, payload: node.msg.completed }, null]);
|
|
@@ -794,7 +796,7 @@ module.exports = function (RED) {
|
|
|
794
796
|
// Output the array of files
|
|
795
797
|
|
|
796
798
|
// Signal end playing
|
|
797
|
-
setTimeout(() => {
|
|
799
|
+
let t = setTimeout(() => {
|
|
798
800
|
node.msg.completed = true;
|
|
799
801
|
node.currentMSGbeingSpoken = {};
|
|
800
802
|
node.send([{ passThroughMessage: node.passThroughMessage, payload: node.msg.completed, filesArray: noPlayerFileArray }, null]);
|