mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
feat: Implemented server mode
This commit is contained in:
@@ -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'},
|
||||
};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user