From c0e3aace8eea788db9ba9d2efdb745337ff05b8a Mon Sep 17 00:00:00 2001 From: Chandu Date: Sat, 4 Jul 2026 19:47:59 -0400 Subject: [PATCH] Initial upload --- .gitignore | 18 + index.html | 66 +++ package-lock.json | 1074 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 16 + script.js | 631 ++++++++++++++++++++++++++ server.js | 437 ++++++++++++++++++ styles.css | 69 +++ 7 files changed, 2311 insertions(+) create mode 100644 .gitignore create mode 100644 index.html create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 script.js create mode 100644 server.js create mode 100644 styles.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1e46e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +node_modules/ +.env +.env.* +*.log +*.tmp +*.temp +.DS_Store +*.sqlite +*.db +*.pem +*.key +*.p12 +*.pfx +dist/ +build/ +coverage/ +.vscode/ +.idea/ diff --git a/index.html b/index.html new file mode 100644 index 0000000..1ad5ad4 --- /dev/null +++ b/index.html @@ -0,0 +1,66 @@ + + + + + + Voice to Voice & Text Translator + + + +
+

Voice to Voice & Text Translator

+

Speak, translate, and hear the answer in another language.

+ +
+ + + +
+ +
+ +
+ + + +
+
Ready
+
+ +
+

Translation

+
Translation will appear here...
+
+
+ + + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..fa868b4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1074 @@ +{ + "name": "voice-translator-app", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "voice-translator-app", + "version": "1.0.0", + "dependencies": { + "axios": "^1.7.7", + "body-parser": "^1.20.2", + "cors": "^2.8.5", + "dotenv": "^16.0.3", + "express": "^4.21.2", + "google-tts-api": "^2.0.1" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/agent-base/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/agent-base/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.18.1.tgz", + "integrity": "sha512-3nTvFlvpn9Zu/RkHUqtc7/+al4UpRW5az71ap5zccp6e8RAYEzhMTecX8Dz1wWDYrPpUoB1HAQEGEAEvUr7S9g==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.16.0", + "form-data": "^4.0.5", + "https-proxy-agent": "^5.0.1", + "proxy-from-env": "^2.1.0" + } + }, + "node_modules/body-parser": { + "version": "1.20.5", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.5.tgz", + "integrity": "sha512-3grm+/2tUOvu2cjJkvsIxrv/wVpfXQW4PsQHYm7yk4vfpu7Ekl6nEsYBoJUL6qDwZUx8wUhQ8tR2qz+ad9c9OA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.15.1", + "raw-body": "~2.5.3", + "type-is": "~1.6.18", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.22.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.22.2.tgz", + "integrity": "sha512-IuL+Elrou2ZvCFHs18/CIzy2Nzvo25nZ1/D2eIZlz7c+QUayAcYoiM2BthCjs+EBHVpjYjcuLDAiCWgeIX3X1Q==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "~1.20.5", + "content-disposition": "~0.5.4", + "content-type": "~1.0.4", + "cookie": "~0.7.1", + "cookie-signature": "~1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.3.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "~0.1.12", + "proxy-addr": "~2.0.7", + "qs": "~6.15.1", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "~0.19.0", + "serve-static": "~1.16.2", + "setprototypeof": "1.2.0", + "statuses": "~2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", + "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "statuses": "~2.0.2", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/follow-redirects": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.4", + "mime-types": "^2.1.35" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/google-tts-api": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/google-tts-api/-/google-tts-api-2.0.2.tgz", + "integrity": "sha512-MkQYbBJEdom8hJpfEVDfD3tpBtkz0X59C+FNsoRhbnCiFjZRnzyurGQ5OrAr3xkigII56/jmk0JNwZsp450G+Q==", + "license": "MIT", + "dependencies": { + "axios": "^0.21.0" + } + }, + "node_modules/google-tts-api/node_modules/axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/https-proxy-agent/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/https-proxy-agent/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz", + "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==", + "license": "MIT" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/proxy-from-env": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/qs": { + "version": "6.15.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz", + "integrity": "sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==", + "license": "BSD-3-Clause", + "dependencies": { + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz", + "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.4.1", + "range-parser": "~1.2.1", + "statuses": "~2.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", + "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "~0.19.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..dbb83b9 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "voice-translator-app", + "version": "1.0.0", + "main": "server.js", + "scripts": { + "start": "node server.js" + }, + "dependencies": { + "axios": "^1.7.7", + "body-parser": "^1.20.2", + "cors": "^2.8.5", + "dotenv": "^16.0.3", + "express": "^4.21.2", + "google-tts-api": "^2.0.1" + } +} diff --git a/script.js b/script.js new file mode 100644 index 0000000..d9ba028 --- /dev/null +++ b/script.js @@ -0,0 +1,631 @@ +// Mobile Detection +const isMobileApp = () => window.Capacitor !== undefined; +console.log('Mobile App:', isMobileApp()); + +// API URL Configuration +const getApiUrl = () => { + if (isMobileApp()) { + // For mobile apps, use your deployed API URL + // Or local IP for testing: 'http://192.168.1.100:3000' + return localStorage.getItem('apiUrl') || 'http://localhost:3000'; + } + return ''; // Use relative URL for web +}; + +const API_URL = getApiUrl(); +console.log('API URL:', API_URL); + +// Initialize Speech Recognition API +const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; +const recognition = SpeechRecognition ? new SpeechRecognition() : null; + +function isVoiceInputAllowed() { + return window.isSecureContext || + location.protocol === 'https:' || + location.hostname === 'localhost' || + location.hostname === '127.0.0.1' || + location.hostname.endsWith('.local'); +} + +// Initialize Speech Synthesis API +const speechSynthesis = window.speechSynthesis; +let availableVoices = []; +let voicesLoaded = false; +let mediaRecorder = null; +let audioStream = null; +let audioChunks = []; +let isRecording = false; +let autoSpeakAfterVoice = false; + +// DOM Elements +const sourceText = document.getElementById('sourceText'); +const translatedText = document.getElementById('translatedText'); +const sourceLang = document.getElementById('sourceLang'); +const targetLang = document.getElementById('targetLang'); +const voiceBtn = document.getElementById('voiceBtn'); +const clearSourceBtn = document.getElementById('clearSourceBtn') || document.getElementById('clearBtn'); +const speakBtn = document.getElementById('speakBtn'); +const copyBtn = document.getElementById('copyBtn'); +const swapBtn = document.getElementById('swapBtn'); +const voiceStatus = document.getElementById('voiceStatus'); +const statusMessage = document.getElementById('statusMessage') || document.getElementById('status'); +const charCount = document.getElementById('charCount'); +const copyFeedback = document.getElementById('copyFeedback'); + +// Language codes for speech recognition and synthesis +const langMap = { + 'en': 'en-US', + 'es': 'es-ES', + 'fr': 'fr-FR', + 'de': 'de-DE', + 'pt': 'pt-BR', + 'it': 'it-IT', + 'nl': 'nl-NL', + 'ru': 'ru-RU', + 'ar': 'ar-SA', + 'ja': 'ja-JP', + 'ko': 'ko-KR', + 'zh': 'zh-CN', + 'hi': 'hi-IN', + 'ta': 'ta-IN', + 'te': 'te-IN', + 'ml': 'ml-IN', + 'pa': 'pa-IN', + 'kn': 'kn-IN', + 'id': 'id-ID', + 'vi': 'vi-VN', + 'tr': 'tr-TR' +}; + +const remoteTtsLanguages = new Set(['ta', 'te', 'ml', 'pa', 'kn']); + +// Initialize +document.addEventListener('DOMContentLoaded', () => { + setupEventListeners(); + + // Check for HTTPS/secure-context requirement for voice input + if (!isVoiceInputAllowed() && !isMobileApp()) { + console.warn('Voice input requires a secure context. Access via https://localhost:3443 for full functionality.'); + } + + // Check voice input support + const voiceSupportAvailable = !!(navigator.mediaDevices?.getUserMedia && window.MediaRecorder); + if (!voiceSupportAvailable) { + console.warn('Voice recording not supported in this browser.'); + if (voiceBtn) { + voiceBtn.disabled = true; + voiceBtn.title = 'Voice input not supported in this browser'; + voiceBtn.style.opacity = '0.5'; + } + } + + // Check speech synthesis support + if (!speechSynthesis) { + console.warn('Speech synthesis not supported in this browser.'); + if (speakBtn) { + speakBtn.disabled = true; + speakBtn.title = 'Text-to-speech not supported in this browser'; + speakBtn.style.opacity = '0.5'; + } + } else { + loadVoices(); + } + + showStatus('Ready to translate!', 'success'); +}); + +// Setup Event Listeners +function setupEventListeners() { + const bind = (element, event, handler) => { + if (element) { + element.addEventListener(event, handler); + } + }; + + bind(sourceText, 'input', handleTextInput); + bind(voiceBtn, 'click', handleVoiceInput); + bind(clearSourceBtn, 'click', clearInput); + bind(speakBtn, 'click', speakTranslation); + bind(copyBtn, 'click', copyTranslation); + bind(swapBtn, 'click', swapLanguages); + bind(sourceLang, 'change', translateOnChange); + bind(targetLang, 'change', translateOnChange); + + if (recognition) { + recognition.addEventListener('start', () => { + voiceBtn.classList.add('listening'); + voiceStatus.textContent = '๐ŸŽค Listening...'; + }); + + recognition.addEventListener('result', handleSpeechResult); + + recognition.addEventListener('end', () => { + voiceBtn.classList.remove('listening'); + voiceStatus.textContent = ''; + }); + + recognition.addEventListener('error', (e) => { + console.error('Speech recognition error:', e.error); + let errorMessage = ''; + + switch(e.error) { + case 'no-speech': + errorMessage = 'No speech detected. Please try again.'; + break; + case 'audio-capture': + errorMessage = 'Audio capture failed. Check your microphone.'; + break; + case 'not-allowed': + errorMessage = 'Microphone permission denied.'; + break; + case 'network': + errorMessage = 'Network error during speech recognition.'; + break; + case 'service-not-allowed': + errorMessage = 'Speech recognition service not allowed.'; + break; + default: + errorMessage = `Speech recognition error: ${e.error}`; + } + + voiceStatus.textContent = `โŒ ${errorMessage}`; + voiceBtn.classList.remove('listening'); + showStatus(errorMessage, 'error'); + }); + } +} + +// Handle Text Input +function handleTextInput(e) { + const text = e.target.value; + if (charCount) { + charCount.textContent = text.length; + } + + if (text.trim().length > 0) { + debounceTranslate(); + } else { + translatedText.textContent = ''; + } +} + +// Debounce Translation +let translateTimeout; +function debounceTranslate() { + clearTimeout(translateTimeout); + translateTimeout = setTimeout(() => { + translateText(); + }, 500); +} + +// Translate Text +async function translateText() { + const text = sourceText.value.trim(); + if (!text) return; + + const source = sourceLang.value; + const target = targetLang.value; + + if (source === target) { + translatedText.textContent = text; + return; + } + + try { + showStatus('Translating...', 'loading'); + const response = await fetch(`${API_URL}/api/translate`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + text: text, + sourceLang: source, + targetLang: target + }) + }); + + if (!response.ok) { + throw new Error('Translation failed'); + } + + const data = await response.json(); + translatedText.textContent = data.translatedText; + showStatus('Translation complete!', 'success'); + + if (autoSpeakAfterVoice) { + autoSpeakAfterVoice = false; + speakTranslation(); + } + } catch (error) { + console.error('Translation error:', error); + // Fallback to client-side translation using simple mapping + translatedText.textContent = text; // Fallback: show original text + showStatus('Using direct translation (server unavailable)', 'error'); + } +} + +// Handle Voice Input +async function handleVoiceInput() { + if (!navigator.mediaDevices?.getUserMedia || !window.MediaRecorder) { + showStatus('Voice recording is not supported in this browser.', 'error'); + return; + } + + if (!isVoiceInputAllowed() && !isMobileApp()) { + showStatus('Voice input requires a secure context. Please access via https://localhost:3443', 'error'); + return; + } + + if (isRecording) { + if (mediaRecorder && mediaRecorder.state !== 'inactive') { + mediaRecorder.stop(); + } + isRecording = false; + voiceBtn.classList.remove('listening'); + voiceStatus.textContent = '๐Ÿ”„ Processing voice...'; + return; + } + + try { + audioChunks = []; + const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); + audioStream = stream; + + const mimeType = MediaRecorder.isTypeSupported('audio/webm') ? 'audio/webm' : 'audio/mp4'; + mediaRecorder = new MediaRecorder(stream, { mimeType }); + + mediaRecorder.ondataavailable = (event) => { + if (event.data.size > 0) { + audioChunks.push(event.data); + } + }; + + mediaRecorder.onstop = async () => { + const blob = new Blob(audioChunks, { type: mediaRecorder.mimeType || 'audio/webm' }); + if (audioStream) { + audioStream.getTracks().forEach(track => track.stop()); + audioStream = null; + } + await transcribeAudio(blob); + }; + + mediaRecorder.start(); + isRecording = true; + voiceBtn.classList.add('listening'); + voiceStatus.textContent = '๐ŸŽค Listening...'; + showStatus('Listening for voice input...', 'success'); + } catch (error) { + console.error('Microphone permission denied:', error); + showStatus('Microphone permission required for voice input', 'error'); + voiceStatus.textContent = 'โŒ Microphone access denied'; + } +} + +async function transcribeAudio(blob) { + try { + const response = await fetch(`${API_URL}/api/transcribe`, { + method: 'POST', + headers: { + 'Content-Type': blob.type || 'audio/webm' + }, + body: blob + }); + + if (!response.ok) { + throw new Error('Transcription failed'); + } + + const data = await response.json(); + const transcript = data.transcript || ''; + sourceText.value = transcript; + if (charCount) { + charCount.textContent = transcript.length; + } + if (voiceStatus) { + voiceStatus.textContent = 'โœ“ Voice captured'; + } + autoSpeakAfterVoice = true; + await translateText(); + } catch (error) { + console.error('Voice transcription error:', error); + showStatus('Voice transcription failed', 'error'); + voiceStatus.textContent = 'โŒ Voice transcription failed'; + } +} + +function loadVoices() { + if (!speechSynthesis || typeof speechSynthesis.getVoices !== 'function') return; + + availableVoices = speechSynthesis.getVoices(); + voicesLoaded = availableVoices.length > 0; + + if (!voicesLoaded) { + speechSynthesis.onvoiceschanged = () => { + availableVoices = speechSynthesis.getVoices(); + voicesLoaded = availableVoices.length > 0; + }; + } +} + +function getPreferredVoice(languageCode) { + if (!speechSynthesis || !availableVoices.length) return null; + + const normalizedCode = languageCode.toLowerCase(); + const directMatch = availableVoices.find(voice => voice.lang && voice.lang.toLowerCase() === normalizedCode); + if (directMatch) return directMatch; + + const languageMatch = availableVoices.find(voice => voice.lang && voice.lang.toLowerCase().startsWith(normalizedCode)); + if (languageMatch) return languageMatch; + + return availableVoices.find(voice => voice.localService) || availableVoices[0] || null; +} + +// Handle Speech Result +function handleSpeechResult(event) { + let transcript = ''; + let isFinal = false; + + for (let i = event.resultIndex; i < event.results.length; i++) { + transcript += event.results[i][0].transcript; + if (event.results[i].isFinal) { + isFinal = true; + } + } + + // Show interim results + sourceText.value = transcript; + if (charCount) { + charCount.textContent = transcript.length; + } + + if (isFinal) { + voiceStatus.textContent = 'โœ“ Transcribed successfully'; + setTimeout(() => { + voiceStatus.textContent = ''; + }, 2000); + translateText(); + } else { + voiceStatus.textContent = '๐ŸŽค Listening... (interim)'; + } +} + +// Speak Translation +function speakTranslation() { + if (!speechSynthesis) { + showStatus('Text-to-speech is not supported in this browser', 'error'); + return; + } + + const text = translatedText.textContent?.trim(); + + if (!text || text === 'Translation will appear here...') { + showStatus('Nothing to speak', 'error'); + return; + } + + const speakText = () => { + speechSynthesis.cancel(); + speechSynthesis.resume(); + + const utterance = new SpeechSynthesisUtterance(text.replace(/\s+/g, ' ')); + utterance.lang = langMap[targetLang.value] || 'en-US'; + utterance.rate = 0.95; + utterance.pitch = 1; + utterance.volume = 1; + + const preferredVoice = getPreferredVoice(utterance.lang); + const useRemote = remoteTtsLanguages.has(targetLang.value) && !!API_URL; + + if (useRemote) { + speakWithRemoteTts(text, targetLang.value, utterance, preferredVoice); + return; + } + + if (preferredVoice) { + utterance.voice = preferredVoice; + } + + utterance.onstart = () => { + speakBtn.disabled = true; + showStatus('Speaking...', 'success'); + }; + + utterance.onend = () => { + speakBtn.disabled = false; + showStatus('Done speaking', 'success'); + }; + + utterance.onerror = (e) => { + speakBtn.disabled = false; + showStatus(`Speech error: ${e.error}`, 'error'); + }; + + speechSynthesis.speak(utterance); + }; + + if (!voicesLoaded && typeof speechSynthesis.getVoices === 'function') { + loadVoices(); + window.setTimeout(speakText, 250); + } else { + speakText(); + } +} + +async function speakWithRemoteTts(text, targetLang, utterance, preferredVoice) { + if (!API_URL) { + showStatus('Cannot generate speech without a server URL', 'error'); + return; + } + + try { + showStatus('Generating speech...', 'loading'); + speakBtn.disabled = true; + + const response = await fetch(`${API_URL}/api/speak`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ text, targetLang }) + }); + + if (!response.ok) { + throw new Error('Remote speech generation failed'); + } + + const data = await response.json(); + if (!data.audio) { + throw new Error('No audio returned from speech service'); + } + + const audioType = data.format || 'audio/wav'; + const audio = new Audio(`data:${audioType};base64,${data.audio}`); + audio.onended = () => { + speakBtn.disabled = false; + showStatus('Done speaking', 'success'); + }; + audio.onerror = (e) => { + console.error('Remote audio playback error', e); + if (preferredVoice) { + utterance.voice = preferredVoice; + } + utterance.onstart = () => { + speakBtn.disabled = true; + showStatus('Speaking...', 'success'); + }; + utterance.onend = () => { + speakBtn.disabled = false; + showStatus('Done speaking', 'success'); + }; + utterance.onerror = (err) => { + speakBtn.disabled = false; + showStatus(`Speech error: ${err.error}`, 'error'); + }; + speechSynthesis.speak(utterance); + }; + + await audio.play(); + } catch (error) { + console.warn('Remote TTS failed, falling back to browser speech:', error); + if (preferredVoice) { + utterance.voice = preferredVoice; + } + utterance.onstart = () => { + speakBtn.disabled = true; + showStatus('Speaking...', 'success'); + }; + utterance.onend = () => { + speakBtn.disabled = false; + showStatus('Done speaking', 'success'); + }; + utterance.onerror = (err) => { + speakBtn.disabled = false; + showStatus(`Speech error: ${err.error}`, 'error'); + }; + speechSynthesis.speak(utterance); + } +} + +// Copy Translation +function copyTranslation() { + const text = translatedText.textContent; + + if (!text || text === 'Translation will appear here...') { + showStatus('Nothing to copy', 'error'); + return; + } + + navigator.clipboard.writeText(text).then(() => { + if (copyFeedback) { + copyFeedback.textContent = 'โœ“ Copied!'; + setTimeout(() => { + copyFeedback.textContent = ''; + }, 2000); + } + showStatus('Copied to clipboard', 'success'); + }).catch(err => { + showStatus('Failed to copy', 'error'); + }); +} + +// Clear Input +function clearInput() { + sourceText.value = ''; + translatedText.textContent = ''; + if (charCount) { + charCount.textContent = '0'; + } + if (voiceStatus) { + voiceStatus.textContent = ''; + } + autoSpeakAfterVoice = false; + showStatus('Cleared', 'success'); +} + +// Swap Languages +function swapLanguages() { + const temp = sourceLang.value; + sourceLang.value = targetLang.value; + targetLang.value = temp; + + const tempText = sourceText.value; + sourceText.value = translatedText.textContent === 'Translation will appear here...' + ? '' + : translatedText.textContent; + translatedText.textContent = tempText || ''; + + if (charCount) { + charCount.textContent = sourceText.value.length; + } + translateOnChange(); +} + +// Translate on Language Change +function translateOnChange() { + if (sourceText.value.trim().length > 0) { + translateText(); + } +} + +// Show Status Message +function showStatus(message, type = 'info') { + if (!statusMessage) return; + + statusMessage.textContent = message; + statusMessage.className = type; + + if (type === 'loading') { + statusMessage.style.opacity = '0.7'; + } else { + statusMessage.style.opacity = '1'; + } +} + +// Fallback: Simple offline translation (for demo purposes) +const translationMap = { + 'en-es': { + 'hello': 'hola', + 'goodbye': 'adiรณs', + 'thank you': 'gracias', + 'please': 'por favor', + 'yes': 'sรญ', + 'no': 'no' + }, + 'en-fr': { + 'hello': 'bonjour', + 'goodbye': 'au revoir', + 'thank you': 'merci', + 'please': 's\'il vous plaรฎt', + 'yes': 'oui', + 'no': 'non' + } +}; + +console.log('โœ“ Translator app loaded successfully'); +console.log('Features available:'); +console.log('- Text translation'); +console.log('- Voice input (if supported by browser)'); +console.log('- Text-to-speech output'); +console.log('- Language swapping'); +console.log('- Copy to clipboard'); diff --git a/server.js b/server.js new file mode 100644 index 0000000..89d261c --- /dev/null +++ b/server.js @@ -0,0 +1,437 @@ +const express = require('express'); +const cors = require('cors'); +const bodyParser = require('body-parser'); +const axios = require('axios'); +const path = require('path'); +const googleTTS = require('google-tts-api'); +require('dotenv').config(); + +const HUGGINGFACE_API_TOKEN = process.env.HUGGINGFACEHUB_API_TOKEN || process.env.HF_API_TOKEN; +const huggingFaceLangMap = { + 'en': 'eng', + 'es': 'spa', + 'fr': 'fra', + 'de': 'deu', + 'pt': 'por', + 'it': 'ita', + 'nl': 'nld', + 'ru': 'rus', + 'ar': 'ara', + 'ja': 'jpn', + 'ko': 'kor', + 'zh': 'zho', + 'hi': 'hin', + 'ta': 'tam', + 'te': 'tel', + 'ml': 'mal', + 'pa': 'pan', + 'kn': 'kan', + 'id': 'ind', + 'vi': 'vie', + 'tr': 'tur' +}; + +const app = express(); +const PORT = process.env.PORT || 3000; + +// Middleware +app.use(cors()); +app.use(bodyParser.json({ limit: '10mb' })); +app.use(bodyParser.urlencoded({ limit: '10mb', extended: true })); +app.use(bodyParser.raw({ type: 'audio/*', limit: '10mb' })); +app.use(express.static(path.join(__dirname))); + +// Language code mapping +const langMap = { + 'en': 'en', + 'es': 'es', + 'fr': 'fr', + 'de': 'de', + 'pt': 'pt', + 'ja': 'ja', + 'ko': 'ko', + 'zh': 'zh-CN', + 'ta': 'ta', + 'te': 'te', + 'ml': 'ml', + 'hi': 'hi' +}; + +// Translation API endpoint (using free mymemory translation API) +const translateViaMyMemory = async (text, sourceLang, targetLang) => { + try { + const response = await axios.get('https://api.mymemory.translated.net/get', { + params: { + q: text, + langpair: `${sourceLang}|${targetLang}` + } + }); + + if (response.data.responseStatus === 200) { + return response.data.responseData.translatedText; + } + throw new Error('Translation failed'); + } catch (error) { + console.error('MyMemory translation error:', error.message); + return null; + } +}; + +// Hugging Face translation via M2M100 +const translateViaHuggingFace = async (text, sourceLang, targetLang) => { + if (!HUGGINGFACE_API_TOKEN) { + return null; + } + + const srcCode = huggingFaceLangMap[sourceLang] || 'eng'; + const tgtCode = huggingFaceLangMap[targetLang] || 'eng'; + + try { + const response = await axios.post( + 'https://api-inference.huggingface.co/models/facebook/m2m100_418M', + { + inputs: text, + parameters: { + src_lang: srcCode, + tgt_lang: tgtCode + } + }, + { + headers: { + Authorization: `Bearer ${HUGGINGFACE_API_TOKEN}`, + 'Content-Type': 'application/json' + }, + timeout: 20000 + } + ); + + const data = response.data; + if (Array.isArray(data) && data[0]?.generated_text) { + return data[0].generated_text; + } + if (data?.generated_text) { + return data.generated_text; + } + if (typeof data === 'string') { + return data; + } + + return null; + } catch (error) { + console.error('Hugging Face translation error:', error.message || error); + return null; + } +}; + +// Hugging Face text-to-speech +const ttsLangMap = { + 'en': 'en-US', + 'es': 'es-ES', + 'fr': 'fr-FR', + 'de': 'de-DE', + 'pt': 'pt-BR', + 'it': 'it-IT', + 'nl': 'nl-NL', + 'ru': 'ru-RU', + 'ar': 'ar-SA', + 'ja': 'ja-JP', + 'ko': 'ko-KR', + 'zh': 'zh-CN', + 'hi': 'hi-IN', + 'ta': 'ta-IN', + 'te': 'te-IN', + 'ml': 'ml-IN', + 'pa': 'pa-IN', + 'kn': 'kn-IN', + 'id': 'id-ID', + 'vi': 'vi-VN', + 'tr': 'tr-TR' +}; + +const speakViaHuggingFace = async (text, targetLang) => { + const normalizedLang = (targetLang || 'en').toLowerCase(); + if (!HUGGINGFACE_API_TOKEN) { + return await speakViaGoogleTts(text, normalizedLang); + } + const ttsLang = ttsLangMap[normalizedLang] || 'en-US'; + const preferredModels = []; + + if (['ta', 'te', 'ml', 'kn', 'pa', 'hi'].includes(normalizedLang)) { + const languageModelMap = { + 'ta': 'facebook/mms-tts-ta', + 'te': 'facebook/mms-tts-te', + 'ml': 'facebook/mms-tts-ml', + 'kn': 'facebook/mms-tts-kn', + 'pa': 'facebook/mms-tts-pa', + 'hi': 'facebook/mms-tts-hi' + }; + preferredModels.push(languageModelMap[normalizedLang]); + } + + preferredModels.push( + 'microsoft/speecht5_tts', + 'tts_models/multilingual/multi-dataset/your_tts' + ); + + for (const model of preferredModels) { + try { + const payload = model.includes('mms-tts') + ? { inputs: text } + : model.includes('speecht5') + ? { + inputs: text, + parameters: { + language: ttsLang, + voice: 'alloy' + } + } + : { + inputs: text, + parameters: { + speaker: 'alloy', + language: ttsLang + } + }; + + const response = await axios.post( + `https://api-inference.huggingface.co/models/${model}`, + payload, + { + headers: { + Authorization: `Bearer ${HUGGINGFACE_API_TOKEN}`, + 'Content-Type': 'application/json', + Accept: 'audio/*' + }, + responseType: 'arraybuffer', + timeout: 60000 + } + ); + + const contentType = response.headers['content-type'] || 'audio/wav'; + if (response.data && contentType.includes('audio')) { + return { + audio: Buffer.from(response.data).toString('base64'), + format: contentType.includes('mpeg') ? 'audio/mpeg' : 'audio/wav' + }; + } + } catch (error) { + console.warn(`Hugging Face TTS model ${model} failed:`, error.message || error); + } + } + + return await speakViaGoogleTts(text, normalizedLang); +}; + +const speakViaGoogleTts = async (text, targetLang) => { + try { + const url = googleTTS.getAudioUrl(text, { + lang: targetLang, + slow: false, + host: 'https://translate.google.com', + splitPunctuation: '.?' + }); + + const response = await axios.get(url, { + responseType: 'arraybuffer', + headers: { + 'User-Agent': 'Mozilla/5.0 (compatible; GoogleTTS/1.0)' + }, + timeout: 20000 + }); + + if (response.data) { + return { + audio: Buffer.from(response.data).toString('base64'), + format: 'audio/mpeg' + }; + } + } catch (error) { + console.warn('Google TTS fallback failed:', error.message || error); + } + + return null; +}; + +// Alternative: Using LibreTranslate if available locally +const translateViaLibreTranslate = async (text, sourceLang, targetLang) => { + try { + const response = await axios.post('http://localhost:5000/translate', { + q: text, + source: sourceLang, + target: targetLang + }, { + timeout: 5000 + }); + return response.data.translatedText; + } catch (error) { + console.warn('LibreTranslate not available, trying MyMemory...'); + return null; + } +}; + +// Speech-to-text endpoint using Hugging Face Whisper +app.post('/api/transcribe', async (req, res) => { + try { + const audioBuffer = req.body; + if (!audioBuffer || audioBuffer.length === 0) { + return res.status(400).json({ error: 'No audio provided' }); + } + + if (!HUGGINGFACE_API_TOKEN) { + return res.status(500).json({ error: 'Hugging Face token not configured' }); + } + + const contentType = req.headers['content-type'] || 'application/octet-stream'; + const response = await axios.post( + 'https://api-inference.huggingface.co/models/openai/whisper-large-v3', + audioBuffer, + { + headers: { + Authorization: `Bearer ${HUGGINGFACE_API_TOKEN}`, + 'Content-Type': contentType + }, + timeout: 60000 + } + ); + + const data = response.data; + const transcript = Array.isArray(data) ? data[0]?.text : data?.text || ''; + res.json({ transcript }); + } catch (error) { + console.error('Speech-to-text error:', error.message || error); + res.status(500).json({ error: 'Speech-to-text failed' }); + } +}); + +// Translation endpoint +app.post('/api/translate', async (req, res) => { + try { + const { text, sourceLang, targetLang } = req.body; + + // Validate input + if (!text || !sourceLang || !targetLang) { + return res.status(400).json({ error: 'Missing required fields' }); + } + + if (text.length > 5000) { + return res.status(400).json({ error: 'Text exceeds 5000 character limit' }); + } + + // If source and target languages are the same + if (sourceLang === targetLang) { + return res.json({ translatedText: text }); + } + + console.log(`Translating "${text.substring(0, 50)}..." from ${sourceLang} to ${targetLang}`); + + // Try Hugging Face first if the key is configured + let translatedText = await translateViaHuggingFace(text, sourceLang, targetLang); + + // Fallback to LibreTranslate if available locally + if (!translatedText) { + translatedText = await translateViaLibreTranslate(text, sourceLang, targetLang); + } + + // Fallback to MyMemory if other services are unavailable + if (!translatedText) { + translatedText = await translateViaMyMemory(text, sourceLang, targetLang); + } + + if (!translatedText) { + return res.status(500).json({ + error: 'Translation service unavailable', + translatedText: text // Fallback to original text + }); + } + + res.json({ translatedText }); + } catch (error) { + console.error('Translation error:', error); + res.status(500).json({ error: 'Internal server error' }); + } +}); + +app.post('/api/speak', async (req, res) => { + try { + const { text, targetLang } = req.body; + + if (!text || !targetLang) { + return res.status(400).json({ error: 'Missing required fields' }); + } + + const speechResult = await speakViaHuggingFace(text, targetLang); + if (!speechResult?.audio) { + return res.status(500).json({ error: 'Speech service unavailable' }); + } + + res.json({ audio: speechResult.audio, format: speechResult.format || 'audio/wav' }); + } catch (error) { + console.error('Speech endpoint error:', error); + res.status(500).json({ error: 'Internal server error' }); + } +}); + +// Health check endpoint +app.get('/api/health', (req, res) => { + res.json({ status: 'healthy', message: 'Translator API is running' }); +}); + +// Get supported languages +app.get('/api/languages', (req, res) => { + const languages = { + 'en': 'English', + 'es': 'Spanish', + 'fr': 'French', + 'de': 'German', + 'pt': 'Portuguese', + 'it': 'Italian', + 'nl': 'Dutch', + 'ru': 'Russian', + 'ar': 'Arabic', + 'ja': 'Japanese', + 'ko': 'Korean', + 'zh': 'Chinese (Simplified)', + 'hi': 'Hindi', + 'ta': 'Tamil', + 'te': 'Telugu', + 'ml': 'Malayalam', + 'pa': 'Punjabi', + 'kn': 'Kannada', + 'id': 'Indonesian', + 'vi': 'Vietnamese', + 'tr': 'Turkish' + }; + res.json(languages); +}); + +// Main app page +app.get('/', (req, res) => { + res.sendFile(path.join(__dirname, 'index.html')); +}); + +// 404 handler +app.use((req, res) => { + res.status(404).json({ error: 'Not Found' }); +}); + +// Error handler +app.use((err, req, res, next) => { + console.error('Server error:', err); + res.status(500).json({ error: 'Internal Server Error' }); +}); + +// Start server +app.listen(PORT, () => { + console.log(` + ======================================== + ๐ŸŒ Language Translator Server + ======================================== + Server running on: http://localhost:${PORT} + + Available endpoints: + - POST /api/translate - Translate text + - GET /api/languages - Get supported languages + - GET /api/health - Health check + ======================================== + `); +}); diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..5f5148b --- /dev/null +++ b/styles.css @@ -0,0 +1,69 @@ +body { + font-family: Arial, sans-serif; + background: #0f172a; + color: #f8fafc; + margin: 0; + padding: 24px; +} +.app { + max-width: 860px; + margin: 0 auto; + background: #111827; + border-radius: 16px; + padding: 24px; + box-shadow: 0 10px 30px rgba(0,0,0,0.25); +} +.controls { + display: flex; + gap: 16px; + margin-bottom: 16px; +} +label { + display: flex; + flex-direction: column; + gap: 6px; + font-weight: 600; +} +select, textarea, button { + border-radius: 10px; + border: 1px solid #334155; + padding: 10px 12px; + font-size: 1rem; +} +textarea { + width: 100%; + min-height: 140px; + resize: vertical; + margin-bottom: 12px; +} +.buttons { + display: flex; + gap: 10px; + flex-wrap: wrap; +} +button { + cursor: pointer; + background: #2563eb; + color: white; +} +button:disabled { + opacity: 0.6; + cursor: not-allowed; +} +.panel { + background: #1f2937; + border-radius: 12px; + padding: 16px; + margin-top: 16px; +} +.output #translatedText { + min-height: 80px; + padding: 12px; + background: #111827; + border-radius: 10px; +} +.status { + margin-top: 10px; + font-size: 0.95rem; + color: #93c5fd; +}