From 21dfb6b70de12ff21ed09ade1a0722c43d948db6 Mon Sep 17 00:00:00 2001 From: Wuriko Date: Sun, 6 Oct 2024 11:34:38 +0200 Subject: [PATCH 01/12] doc: add custom engine api doc --- examples/custom-engine-api/README.md | 48 +++++++++++++ .../custom-engine-api/bruno/List Voices.bru | 19 +++++ .../bruno/Synthesize Speech.bru | 28 ++++++++ examples/custom-engine-api/bruno/bruno.json | 9 +++ .../custom-engine-api/postman/postman.json | 71 +++++++++++++++++++ 5 files changed, 175 insertions(+) create mode 100644 examples/custom-engine-api/README.md create mode 100644 examples/custom-engine-api/bruno/List Voices.bru create mode 100644 examples/custom-engine-api/bruno/Synthesize Speech.bru create mode 100644 examples/custom-engine-api/bruno/bruno.json create mode 100644 examples/custom-engine-api/postman/postman.json diff --git a/examples/custom-engine-api/README.md b/examples/custom-engine-api/README.md new file mode 100644 index 00000000..8834059d --- /dev/null +++ b/examples/custom-engine-api/README.md @@ -0,0 +1,48 @@ +# Custom Engine Api + +## List Voices + +### Method: POST + +``` +http://localhost:3000/list-voices +``` + +### Body (**raw**) + +```json +{ + "credentials": { + "apiKey": "" + } +} +``` + +⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ + +## Synthesize Speech + +### Method: POST + +``` +http://localhost:3000/synthesize-speech +``` + +### Body (**raw**) + +```json +{ + "credentials": { + "apiKey": "" + }, + "payload": { + "text": "Hello world, programmed to work and not to feel.", + "voice": { + "id": "Microsoft Hazel Desktop", + "name": "Microsoft Hazel Desktop", + "category": "Say", + "languageCode": "en-US" + } + } +} +``` diff --git a/examples/custom-engine-api/bruno/List Voices.bru b/examples/custom-engine-api/bruno/List Voices.bru new file mode 100644 index 00000000..5846c5f6 --- /dev/null +++ b/examples/custom-engine-api/bruno/List Voices.bru @@ -0,0 +1,19 @@ +meta { + name: List Voices + type: http + seq: 2 +} + +post { + url: http://localhost:3000/list-voices + body: json + auth: none +} + +body:json { + { + "credentials": { + "apiKey": "" + } + } +} diff --git a/examples/custom-engine-api/bruno/Synthesize Speech.bru b/examples/custom-engine-api/bruno/Synthesize Speech.bru new file mode 100644 index 00000000..d58b0c8d --- /dev/null +++ b/examples/custom-engine-api/bruno/Synthesize Speech.bru @@ -0,0 +1,28 @@ +meta { + name: Synthesize Speech + type: http + seq: 3 +} + +post { + url: http://localhost:3000/synthesize-speech + body: json + auth: none +} + +body:json { + { + "credentials": { + "apiKey": "" + }, + "payload": { + "text": "Hello world, programmed to work and not to feel.", + "voice": { + "id": "Microsoft Hazel Desktop", + "name": "Microsoft Hazel Desktop", + "category": "Say", + "languageCode": "en-US" + } + } + } +} diff --git a/examples/custom-engine-api/bruno/bruno.json b/examples/custom-engine-api/bruno/bruno.json new file mode 100644 index 00000000..7c60eb8b --- /dev/null +++ b/examples/custom-engine-api/bruno/bruno.json @@ -0,0 +1,9 @@ +{ + "version": "1", + "name": "Custom Engine Api", + "type": "collection", + "ignore": [ + "node_modules", + ".git" + ] +} \ No newline at end of file diff --git a/examples/custom-engine-api/postman/postman.json b/examples/custom-engine-api/postman/postman.json new file mode 100644 index 00000000..4dbd511d --- /dev/null +++ b/examples/custom-engine-api/postman/postman.json @@ -0,0 +1,71 @@ +{ + "info": { + "name": "Custom Engine Api", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "List Voices", + "event": [], + "request": { + "method": "POST", + "header": [], + "auth": null, + "description": "", + "url": { + "raw": "http://localhost:3000/list-voices", + "protocol": "http", + "host": [ + "localhost:3000" + ], + "path": [ + "list-voices" + ], + "query": [], + "variable": [] + }, + "body": { + "mode": "raw", + "raw": "{\n \"credentials\": {\n \"apiKey\": \"\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + } + } + }, + { + "name": "Synthesize Speech", + "event": [], + "request": { + "method": "POST", + "header": [], + "auth": null, + "description": "", + "url": { + "raw": "http://localhost:3000/synthesize-speech", + "protocol": "http", + "host": [ + "localhost:3000" + ], + "path": [ + "synthesize-speech" + ], + "query": [], + "variable": [] + }, + "body": { + "mode": "raw", + "raw": "{\n \"credentials\": {\n \"apiKey\": \"\"\n },\n \"payload\": {\n \"text\": \"Hello world, programmed to work and not to feel.\",\n \"voice\": {\n \"id\": \"Microsoft Hazel Desktop\",\n \"name\": \"Microsoft Hazel Desktop\",\n \"category\": \"Say\",\n \"languageCode\": \"en-US\"\n }\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + } + } + } + ], + "variable": [] +} From a14a469185657fbe75d8589022b01f29638809fc Mon Sep 17 00:00:00 2001 From: Wurielle Date: Sun, 6 Oct 2024 09:35:12 +0000 Subject: [PATCH 02/12] style: prettier formatting --- examples/custom-engine-api/bruno/bruno.json | 7 ++----- examples/custom-engine-api/postman/postman.json | 16 ++++------------ 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/examples/custom-engine-api/bruno/bruno.json b/examples/custom-engine-api/bruno/bruno.json index 7c60eb8b..cbd986e5 100644 --- a/examples/custom-engine-api/bruno/bruno.json +++ b/examples/custom-engine-api/bruno/bruno.json @@ -2,8 +2,5 @@ "version": "1", "name": "Custom Engine Api", "type": "collection", - "ignore": [ - "node_modules", - ".git" - ] -} \ No newline at end of file + "ignore": ["node_modules", ".git"] +} diff --git a/examples/custom-engine-api/postman/postman.json b/examples/custom-engine-api/postman/postman.json index 4dbd511d..5a821856 100644 --- a/examples/custom-engine-api/postman/postman.json +++ b/examples/custom-engine-api/postman/postman.json @@ -15,12 +15,8 @@ "url": { "raw": "http://localhost:3000/list-voices", "protocol": "http", - "host": [ - "localhost:3000" - ], - "path": [ - "list-voices" - ], + "host": ["localhost:3000"], + "path": ["list-voices"], "query": [], "variable": [] }, @@ -46,12 +42,8 @@ "url": { "raw": "http://localhost:3000/synthesize-speech", "protocol": "http", - "host": [ - "localhost:3000" - ], - "path": [ - "synthesize-speech" - ], + "host": ["localhost:3000"], + "path": ["synthesize-speech"], "query": [], "variable": [] }, From b68b08fa3dd03f4a7de36b2faa3f2cff64e96ed1 Mon Sep 17 00:00:00 2001 From: Wuriko Date: Sun, 6 Oct 2024 11:48:15 +0200 Subject: [PATCH 03/12] doc: update doc --- examples/custom-engine-api/README.md | 29 ++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/examples/custom-engine-api/README.md b/examples/custom-engine-api/README.md index 8834059d..ac61cd9e 100644 --- a/examples/custom-engine-api/README.md +++ b/examples/custom-engine-api/README.md @@ -2,13 +2,13 @@ ## List Voices -### Method: POST +### Method: `POST` ``` http://localhost:3000/list-voices ``` -### Body (**raw**) +### Body: `application/json` ```json { @@ -18,17 +18,36 @@ http://localhost:3000/list-voices } ``` +### Response: `application/json` + +```json +[ + { + "id": "Microsoft Hazel Desktop", + "name": "Microsoft Hazel Desktop", + "category": "Say", + "languageCode": "en-US" + }, + { + "id": "Microsoft Zira Desktop", + "name": "Microsoft Zira Desktop", + "category": "Say", + "languageCode": "en-US" + } +] +``` + ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ## Synthesize Speech -### Method: POST +### Method: `POST` ``` http://localhost:3000/synthesize-speech ``` -### Body (**raw**) +### Body: `application/json` ```json { @@ -46,3 +65,5 @@ http://localhost:3000/synthesize-speech } } ``` + +### Response: `audio/mp3` From 9f00d57a00de7ef72ff2bd5f71d7e1f76c5fbc12 Mon Sep 17 00:00:00 2001 From: Wuriko Date: Sun, 6 Oct 2024 11:55:01 +0200 Subject: [PATCH 04/12] chore: remove logs --- examples/custom-engine-api/index.js | 143 ++++++++++++++-------------- 1 file changed, 70 insertions(+), 73 deletions(-) diff --git a/examples/custom-engine-api/index.js b/examples/custom-engine-api/index.js index 6f35dc27..4216768a 100644 --- a/examples/custom-engine-api/index.js +++ b/examples/custom-engine-api/index.js @@ -1,6 +1,5 @@ const express = require('express') const app = express() -const port = 3000 const pkg = require('./package.json') const say = require('say') const cors = require('cors') @@ -14,85 +13,83 @@ const ENDPOINT_PORT = 3000 app.use(cors()) app.use(bodyParser.json()) -app.use(bodyParser.urlencoded({ extended: true })) +app.use(bodyParser.urlencoded({extended: true})) app.post('/list-voices', async (req, res) => { - try { - const { - body: { - credentials: { - apiKey, // API key provided by the user if required - }, - }, - } = req - console.log(req.body) - const voices = await new Promise((resolve, reject) => { - say.getInstalledVoices((err, voices) => { - if (err) return reject(err) - return resolve(voices) - }) - }) - res.status(200).json( - voices.map((name) => ({ - id: name, // id must be unique - name, // name of the voice - category: 'Say', // category of the voice - languageCode: 'en-US', // language code of the voice - })), - ) - } catch (err) { - res.status(500).json({ error: err.message }) - } + try { + const { + body: { + credentials: { + apiKey, // API key provided by the user if required + }, + }, + } = req + const voices = await new Promise((resolve, reject) => { + say.getInstalledVoices((err, voices) => { + if (err) return reject(err) + return resolve(voices) + }) + }) + res.status(200).json( + voices.map((name) => ({ + id: name, // id must be unique + name, // name of the voice + category: 'Say', // category of the voice + languageCode: 'en-US', // language code of the voice + })), + ) + } catch (err) { + res.status(500).json({error: err.message}) + } }) app.post('/synthesize-speech', async (req, res) => { - try { - const { - body: { - credentials: { - apiKey, // API key provided by the user if required - }, - payload: { - text, // message to be spoken - voice: { - id, // id must be unique - name, // name of the voice - category, // category of the voice - languageCode, // language code of the voice - }, - }, - }, - } = req - console.log(req.body) - const outputFile = path.join(__dirname, 'example.mp3') - fs.mkdirSync(path.parse(outputFile).dir, { recursive: true }) - fs.writeFileSync(outputFile, '') + try { + const { + body: { + credentials: { + apiKey, // API key provided by the user if required + }, + payload: { + text, // message to be spoken + voice: { + id, // id must be unique + name, // name of the voice + category, // category of the voice + languageCode, // language code of the voice + }, + }, + }, + } = req + const outputFile = path.join(__dirname, 'example.mp3') + fs.mkdirSync(path.parse(outputFile).dir, {recursive: true}) + fs.writeFileSync(outputFile, '') - await new Promise((resolve, reject) => { - say.export(text, name, 1, outputFile, (err) => { - if (err) { - reject(err) - } - resolve(true) - }) - }) + await new Promise((resolve, reject) => { + say.export(text, name, 1, outputFile, (err) => { + if (err) { + reject(err) + } + resolve(true) + }) + }) - res.writeHead(200, { - 'Content-Type': 'audio/mp3', - }) - const stream = fs.createReadStream(outputFile).pipe(res) - stream.on('finish', () => { - fs.unlinkSync(outputFile) - }) - } catch (err) { - res.status(500).json({ error: err.message }) - } + res.writeHead(200, { + 'Content-Type': 'audio/mp3', + }) + const stream = fs.createReadStream(outputFile).pipe(res) + stream.on('finish', () => { + fs.unlinkSync(outputFile) + }) + } catch (err) { + res.status(500).json({error: err.message}) + } }) -app.listen(port, () => { - console.log( - `[${pkg.name}] API endpoint: ${ENDPOINT_BASE_URL}${ - ENDPOINT_PORT ? `:${ENDPOINT_PORT}` : '' - }`, - ) +app.listen(ENDPOINT_PORT, () => { + console.log( + `[${pkg.name}] API endpoint: ${ENDPOINT_BASE_URL}${ + ENDPOINT_PORT ? `:${ENDPOINT_PORT}` : '' + }`, + ) }) From cc543ceca293b7d073422f26719b2e9de0b9b3d5 Mon Sep 17 00:00:00 2001 From: Wurielle Date: Sun, 6 Oct 2024 09:55:31 +0000 Subject: [PATCH 05/12] style: prettier formatting --- examples/custom-engine-api/index.js | 138 ++++++++++++++-------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/examples/custom-engine-api/index.js b/examples/custom-engine-api/index.js index 4216768a..9ddd7224 100644 --- a/examples/custom-engine-api/index.js +++ b/examples/custom-engine-api/index.js @@ -13,83 +13,83 @@ const ENDPOINT_PORT = 3000 app.use(cors()) app.use(bodyParser.json()) -app.use(bodyParser.urlencoded({extended: true})) +app.use(bodyParser.urlencoded({ extended: true })) app.post('/list-voices', async (req, res) => { - try { - const { - body: { - credentials: { - apiKey, // API key provided by the user if required - }, - }, - } = req - const voices = await new Promise((resolve, reject) => { - say.getInstalledVoices((err, voices) => { - if (err) return reject(err) - return resolve(voices) - }) - }) - res.status(200).json( - voices.map((name) => ({ - id: name, // id must be unique - name, // name of the voice - category: 'Say', // category of the voice - languageCode: 'en-US', // language code of the voice - })), - ) - } catch (err) { - res.status(500).json({error: err.message}) - } + try { + const { + body: { + credentials: { + apiKey, // API key provided by the user if required + }, + }, + } = req + const voices = await new Promise((resolve, reject) => { + say.getInstalledVoices((err, voices) => { + if (err) return reject(err) + return resolve(voices) + }) + }) + res.status(200).json( + voices.map((name) => ({ + id: name, // id must be unique + name, // name of the voice + category: 'Say', // category of the voice + languageCode: 'en-US', // language code of the voice + })), + ) + } catch (err) { + res.status(500).json({ error: err.message }) + } }) app.post('/synthesize-speech', async (req, res) => { - try { - const { - body: { - credentials: { - apiKey, // API key provided by the user if required - }, - payload: { - text, // message to be spoken - voice: { - id, // id must be unique - name, // name of the voice - category, // category of the voice - languageCode, // language code of the voice - }, - }, - }, - } = req - const outputFile = path.join(__dirname, 'example.mp3') - fs.mkdirSync(path.parse(outputFile).dir, {recursive: true}) - fs.writeFileSync(outputFile, '') + try { + const { + body: { + credentials: { + apiKey, // API key provided by the user if required + }, + payload: { + text, // message to be spoken + voice: { + id, // id must be unique + name, // name of the voice + category, // category of the voice + languageCode, // language code of the voice + }, + }, + }, + } = req + const outputFile = path.join(__dirname, 'example.mp3') + fs.mkdirSync(path.parse(outputFile).dir, { recursive: true }) + fs.writeFileSync(outputFile, '') - await new Promise((resolve, reject) => { - say.export(text, name, 1, outputFile, (err) => { - if (err) { - reject(err) - } - resolve(true) - }) - }) + await new Promise((resolve, reject) => { + say.export(text, name, 1, outputFile, (err) => { + if (err) { + reject(err) + } + resolve(true) + }) + }) - res.writeHead(200, { - 'Content-Type': 'audio/mp3', - }) - const stream = fs.createReadStream(outputFile).pipe(res) - stream.on('finish', () => { - fs.unlinkSync(outputFile) - }) - } catch (err) { - res.status(500).json({error: err.message}) - } + res.writeHead(200, { + 'Content-Type': 'audio/mp3', + }) + const stream = fs.createReadStream(outputFile).pipe(res) + stream.on('finish', () => { + fs.unlinkSync(outputFile) + }) + } catch (err) { + res.status(500).json({ error: err.message }) + } }) app.listen(ENDPOINT_PORT, () => { - console.log( - `[${pkg.name}] API endpoint: ${ENDPOINT_BASE_URL}${ - ENDPOINT_PORT ? `:${ENDPOINT_PORT}` : '' - }`, - ) + console.log( + `[${pkg.name}] API endpoint: ${ENDPOINT_BASE_URL}${ + ENDPOINT_PORT ? `:${ENDPOINT_PORT}` : '' + }`, + ) }) From ca41d2632a0242fd5d9f9957880bc57c8a9e0c25 Mon Sep 17 00:00:00 2001 From: Wuriko Date: Sun, 6 Oct 2024 13:31:50 +0200 Subject: [PATCH 06/12] fix: fix missing dependencies --- examples/custom-engine-api/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/custom-engine-api/package.json b/examples/custom-engine-api/package.json index ade3edf0..a1aa8055 100644 --- a/examples/custom-engine-api/package.json +++ b/examples/custom-engine-api/package.json @@ -7,6 +7,8 @@ "start": "nodemon index.js" }, "dependencies": { + "body-parser": "^1.20.0", + "cors": "^2.8.5", "express": "^4.20.0", "nodemon": "^2.0.20", "say": "^0.16.0" From f9052dcd482de34d6c55ab89d3bc667173ca56ea Mon Sep 17 00:00:00 2001 From: Wuriko Date: Sat, 12 Oct 2024 15:24:22 +0200 Subject: [PATCH 07/12] feat: update hitbox on resize --- .../app/src/modules/vue-hitboxes/NvHitbox.vue | 28 ++++---- apps/app/src/modules/vue-hitboxes/index.ts | 66 ++++++++++--------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/apps/app/src/modules/vue-hitboxes/NvHitbox.vue b/apps/app/src/modules/vue-hitboxes/NvHitbox.vue index 584932dd..58d8685c 100644 --- a/apps/app/src/modules/vue-hitboxes/NvHitbox.vue +++ b/apps/app/src/modules/vue-hitboxes/NvHitbox.vue @@ -1,6 +1,6 @@