feat: Implemented server mode

This commit is contained in:
Davide Passoni
2024-12-16 17:24:02 +01:00
parent 032b74b57b
commit c2d5d4ea17
20 changed files with 389 additions and 222 deletions

View File

@@ -11,7 +11,7 @@ const generateClient = new textToSpeech.TextToSpeechClient();
module.exports = function () {
router.put("/generate", (req, res, next) => {
const request = {
input: {text: req.body.text},
input: {ssml: `<speak>${req.body.text}</speak>`},
voice: {languageCode: 'en-US', ssmlGender: 'MALE'},
audioConfig: {audioEncoding: 'MP3'},
};

View File

@@ -23,13 +23,20 @@ module.exports = function (configLocation) {
}
if (fs.existsSync(configLocation)) {
let rawdata = fs.readFileSync(configLocation, "utf-8");
const local = ["127.0.0.1", "::ffff:127.0.0.1", "::1"].includes(req.connection.remoteAddress);
const config = JSON.parse(rawdata);
let resConfig = {
frontend: { ...config.frontend },
audio: { ...(config.audio ?? {}) },
controllers: { ...(config.controllers ?? {}) },
profiles: { ...(profiles ?? {}) },
local: local,
};
if (local) {
resConfig["authentication"] = config["authentication"]
}
res.send(
JSON.stringify({
frontend: { ...config.frontend },
audio: { ...(config.audio ?? {}) },
profiles: { ...(profiles ?? {}) },
})
JSON.stringify(resConfig)
);
res.end();
} else {