node-red-contrib-tts-ultimate
Version:
Transforms the text in speech and hear it using Sonos, Google Cast (Chromecast / Nest) or DLNA/UPnP players, or generate an audio file to be used with third parties nodes. Works with voices from Google (without credentials as well), Google TTS, ElevenLabs
29 lines (24 loc) • 1.06 kB
JavaScript
module.exports = function (RED) {
var formidable = import('formidable');
var fs = require('fs');
var path = require('path');
function ownfileultimate(config) {
RED.nodes.createNode(this, config);
var node = this;
node.selectedFile = config.selectedFile || "";
node.priority = config.priority !== undefined ? config.priority : false;
this.on('input', function (msg) {
if (!msg.hasOwnProperty("priority") && node.priority) msg.priority = node.priority;
if (msg.hasOwnProperty("selectedFile")) {
if (msg.hasOwnProperty("selectedFile")) msg.payload = "OwnFile_" + msg.selectedFile.replace(".mp3", "") + ".mp3";
node.send(msg);
} else {
if (msg.payload !== undefined && msg.payload === true || msg.payload === false) {
msg.payload = node.selectedFile;
node.send(msg);
}
}
});
}
RED.nodes.registerType("ownfileultimate", ownfileultimate);
};