├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── config.simple.json ├── index.js ├── package-lock.json ├── package.json ├── res └── .gitkeep └── src └── .gitkeep /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: ['https://www.buymeacoffee.com/gnehs'] -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | config.json 4 | /res/*.srt 5 | /res/*.vtt 6 | /res/*.url 7 | /src/*.srt 8 | /src/*.vtt 9 | /src/*.url 10 | /.idea 11 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 gnehs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | image 2 | 3 | # subtitle-translator 4 | Translate subtitle using ChatGPT 5 | ## Features 6 | - Translate subtitle using ChatGPT `gpt-3.5-turbo` 7 | - Support multiple languages 8 | - Translation according to the preceding and following sentences 9 | ## How to use 10 | - Electron 11 | - You can download the electron app from [here](https://github.com/gnehs/subtitle-translator-electron/releases) 12 | - Node.js 13 | - Get your own API key from [here](https://platform.openai.com/account/api-keys) 14 | - Rename `config.example.json` to `config.json` and fill in your API key and target language. 15 | - Put your subtitle file in `src` folder 16 | - Run `npm install` to install dependencies 17 | - Run `node index.js` to start 18 | - After the translation is done, you can find the translated file in `res` folder 19 | 20 | ## Supported subtitle extensions 21 | - `.srt` 22 | - `.vtt` WebVTT 23 | 24 | ## Contributing 25 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. -------------------------------------------------------------------------------- /config.simple.json: -------------------------------------------------------------------------------- 1 | { 2 | "OPENAI_API_KEY": "", 3 | "TARGET_LANGUAGE": "" 4 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs' 2 | import colors from 'colors' 3 | import { Configuration, OpenAIApi } from 'openai' 4 | import { parseSync, stringifySync } from 'subtitle' 5 | const config = JSON.parse(fs.readFileSync('./config.json', 'utf8')) 6 | 7 | const configuration = new Configuration({ 8 | apiKey: config.OPENAI_API_KEY, 9 | }); 10 | const openai = new OpenAIApi(configuration); 11 | 12 | let subtitles = fs.readdirSync('./src') 13 | let supportExtensions = ['srt', 'vtt'] 14 | for (let subtitleFile of subtitles) { 15 | if (!supportExtensions.includes(subtitleFile.split('.').pop())) continue 16 | let subtitle = fs.readFileSync(`./src/${subtitleFile}`, 'utf8') 17 | subtitle = parseSync(subtitle) 18 | subtitle = subtitle.filter(line => line.type === 'cue') 19 | 20 | let previousSubtitles = [] 21 | 22 | for (let i = 0; i < subtitle.length; i++) { 23 | // for (let i = 0; i < 10; i++) { 24 | let text = subtitle[i].data.text 25 | let input = { Input: text } 26 | if (subtitle[i + 1]) { 27 | input.Next = subtitle[i + 1].data.text 28 | } 29 | let completion; 30 | for (;;) { 31 | try { 32 | completion = await openai.createChatCompletion({ 33 | model: "gpt-3.5-turbo", 34 | messages: [ 35 | { 36 | role: "system", 37 | content: `You are a program responsible for translating subtitles. Your task is to output the specified target language based on the input text. Please do not create the following subtitles on your own. Please do not output any text other than the translation. You will receive the subtitles as array that needs to be translated, as well as the previous translation results and next subtitle. If you need to merge the subtitles with the following line, simply repeat the translation. Please transliterate the person's name into the local language. Target language: ${config.TARGET_LANGUAGE}` 38 | }, 39 | ...previousSubtitles.slice(-4), 40 | { 41 | role: "user", 42 | content: JSON.stringify(input) 43 | } 44 | ], 45 | }, {timeout: 60 * 1000 }); 46 | break; 47 | } catch (e) { 48 | console.error(`Error: ${e}`); 49 | console.log('retrying...'.red); 50 | } 51 | } 52 | let result = completion.data.choices[0].message.content 53 | try { 54 | result = JSON.parse(result).Input 55 | } catch (e) { 56 | try { 57 | result = result.match(/"Input":"(.*?)"/)[1] 58 | } catch (e) { 59 | console.log('###'.red) 60 | console.log(e.toString().red) 61 | console.log(result.red) 62 | console.log('###'.red) 63 | } 64 | } 65 | previousSubtitles.push({ role: "user", content: JSON.stringify(input) }) 66 | previousSubtitles.push({ role: 'assistant', content: JSON.stringify({ ...input, Input: result }) }) 67 | // console.log(`${subtitle[i].data.text}`.blue) 68 | subtitle[i].data.text = `${result}\n${text}` 69 | console.log(`-----------------`.gray) 70 | console.log(`${i + 1} / ${subtitle.length}`.gray) 71 | console.log(`${result}`.green) 72 | console.log(`${text}`.white) 73 | } 74 | fs.writeFileSync(`./res/${subtitleFile}`, stringifySync(subtitle, { format: 'srt' })) 75 | 76 | } -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "subtitle-translator", 3 | "version": "1.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "subtitle-translator", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "colors": "^1.4.0", 13 | "openai": "^3.2.1", 14 | "subtitle": "^4.2.1" 15 | } 16 | }, 17 | "node_modules/@types/multipipe": { 18 | "version": "3.0.1", 19 | "resolved": "https://registry.npmjs.org/@types/multipipe/-/multipipe-3.0.1.tgz", 20 | "integrity": "sha512-9+Nk8vb/C7ugIIRh01ckmoaExhginZiB+0gEqqp2flvE4Dc+xNDl/nNQPykYl88Zyas1nOX6+3g4T56ccWuHcw==", 21 | "dependencies": { 22 | "@types/node": "*" 23 | } 24 | }, 25 | "node_modules/@types/node": { 26 | "version": "18.14.6", 27 | "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.6.tgz", 28 | "integrity": "sha512-93+VvleD3mXwlLI/xASjw0FzKcwzl3OdTCzm1LaRfqgS21gfFtK3zDXM5Op9TeeMsJVOaJ2VRDpT9q4Y3d0AvA==" 29 | }, 30 | "node_modules/asynckit": { 31 | "version": "0.4.0", 32 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 33 | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" 34 | }, 35 | "node_modules/axios": { 36 | "version": "0.26.1", 37 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", 38 | "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", 39 | "dependencies": { 40 | "follow-redirects": "^1.14.8" 41 | } 42 | }, 43 | "node_modules/colors": { 44 | "version": "1.4.0", 45 | "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", 46 | "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", 47 | "engines": { 48 | "node": ">=0.1.90" 49 | } 50 | }, 51 | "node_modules/combined-stream": { 52 | "version": "1.0.8", 53 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 54 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 55 | "dependencies": { 56 | "delayed-stream": "~1.0.0" 57 | }, 58 | "engines": { 59 | "node": ">= 0.8" 60 | } 61 | }, 62 | "node_modules/core-util-is": { 63 | "version": "1.0.3", 64 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", 65 | "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" 66 | }, 67 | "node_modules/delayed-stream": { 68 | "version": "1.0.0", 69 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 70 | "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", 71 | "engines": { 72 | "node": ">=0.4.0" 73 | } 74 | }, 75 | "node_modules/duplexer2": { 76 | "version": "0.1.4", 77 | "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", 78 | "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", 79 | "dependencies": { 80 | "readable-stream": "^2.0.2" 81 | } 82 | }, 83 | "node_modules/follow-redirects": { 84 | "version": "1.15.2", 85 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", 86 | "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", 87 | "funding": [ 88 | { 89 | "type": "individual", 90 | "url": "https://github.com/sponsors/RubenVerborgh" 91 | } 92 | ], 93 | "engines": { 94 | "node": ">=4.0" 95 | }, 96 | "peerDependenciesMeta": { 97 | "debug": { 98 | "optional": true 99 | } 100 | } 101 | }, 102 | "node_modules/form-data": { 103 | "version": "4.0.0", 104 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 105 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 106 | "dependencies": { 107 | "asynckit": "^0.4.0", 108 | "combined-stream": "^1.0.8", 109 | "mime-types": "^2.1.12" 110 | }, 111 | "engines": { 112 | "node": ">= 6" 113 | } 114 | }, 115 | "node_modules/inherits": { 116 | "version": "2.0.4", 117 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 118 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 119 | }, 120 | "node_modules/isarray": { 121 | "version": "1.0.0", 122 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 123 | "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" 124 | }, 125 | "node_modules/mime-db": { 126 | "version": "1.52.0", 127 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 128 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", 129 | "engines": { 130 | "node": ">= 0.6" 131 | } 132 | }, 133 | "node_modules/mime-types": { 134 | "version": "2.1.35", 135 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 136 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 137 | "dependencies": { 138 | "mime-db": "1.52.0" 139 | }, 140 | "engines": { 141 | "node": ">= 0.6" 142 | } 143 | }, 144 | "node_modules/multipipe": { 145 | "version": "4.0.0", 146 | "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-4.0.0.tgz", 147 | "integrity": "sha512-jzcEAzFXoWwWwUbvHCNPwBlTz3WCWe/jPcXSmTfbo/VjRwRTfvLZ/bdvtiTdqCe8d4otCSsPCbhGYcX+eggpKQ==", 148 | "dependencies": { 149 | "duplexer2": "^0.1.2", 150 | "object-assign": "^4.1.0" 151 | } 152 | }, 153 | "node_modules/object-assign": { 154 | "version": "4.1.1", 155 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 156 | "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", 157 | "engines": { 158 | "node": ">=0.10.0" 159 | } 160 | }, 161 | "node_modules/openai": { 162 | "version": "3.2.1", 163 | "resolved": "https://registry.npmjs.org/openai/-/openai-3.2.1.tgz", 164 | "integrity": "sha512-762C9BNlJPbjjlWZi4WYK9iM2tAVAv0uUp1UmI34vb0CN5T2mjB/qM6RYBmNKMh/dN9fC+bxqPwWJZUTWW052A==", 165 | "dependencies": { 166 | "axios": "^0.26.0", 167 | "form-data": "^4.0.0" 168 | } 169 | }, 170 | "node_modules/process-nextick-args": { 171 | "version": "2.0.1", 172 | "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", 173 | "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" 174 | }, 175 | "node_modules/readable-stream": { 176 | "version": "2.3.8", 177 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", 178 | "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", 179 | "dependencies": { 180 | "core-util-is": "~1.0.0", 181 | "inherits": "~2.0.3", 182 | "isarray": "~1.0.0", 183 | "process-nextick-args": "~2.0.0", 184 | "safe-buffer": "~5.1.1", 185 | "string_decoder": "~1.1.1", 186 | "util-deprecate": "~1.0.1" 187 | } 188 | }, 189 | "node_modules/safe-buffer": { 190 | "version": "5.1.2", 191 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 192 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 193 | }, 194 | "node_modules/split2": { 195 | "version": "3.2.2", 196 | "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", 197 | "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", 198 | "dependencies": { 199 | "readable-stream": "^3.0.0" 200 | } 201 | }, 202 | "node_modules/split2/node_modules/readable-stream": { 203 | "version": "3.6.1", 204 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", 205 | "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", 206 | "dependencies": { 207 | "inherits": "^2.0.3", 208 | "string_decoder": "^1.1.1", 209 | "util-deprecate": "^1.0.1" 210 | }, 211 | "engines": { 212 | "node": ">= 6" 213 | } 214 | }, 215 | "node_modules/string_decoder": { 216 | "version": "1.1.1", 217 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", 218 | "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", 219 | "dependencies": { 220 | "safe-buffer": "~5.1.0" 221 | } 222 | }, 223 | "node_modules/strip-bom": { 224 | "version": "4.0.0", 225 | "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", 226 | "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", 227 | "engines": { 228 | "node": ">=8" 229 | } 230 | }, 231 | "node_modules/subtitle": { 232 | "version": "4.2.1", 233 | "resolved": "https://registry.npmjs.org/subtitle/-/subtitle-4.2.1.tgz", 234 | "integrity": "sha512-ohV7DcQAYjoO8SDTZHaD912g6K+JktbLERlkZyuoNWSXboOOdIvuriF4fZC0T6lbVeiqLfR8mmw3CxIJ5+UTuw==", 235 | "dependencies": { 236 | "@types/multipipe": "^3.0.0", 237 | "multipipe": "^4.0.0", 238 | "split2": "^3.2.2", 239 | "strip-bom": "^4.0.0" 240 | }, 241 | "engines": { 242 | "node": ">=10" 243 | } 244 | }, 245 | "node_modules/util-deprecate": { 246 | "version": "1.0.2", 247 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 248 | "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" 249 | } 250 | }, 251 | "dependencies": { 252 | "@types/multipipe": { 253 | "version": "3.0.1", 254 | "resolved": "https://registry.npmjs.org/@types/multipipe/-/multipipe-3.0.1.tgz", 255 | "integrity": "sha512-9+Nk8vb/C7ugIIRh01ckmoaExhginZiB+0gEqqp2flvE4Dc+xNDl/nNQPykYl88Zyas1nOX6+3g4T56ccWuHcw==", 256 | "requires": { 257 | "@types/node": "*" 258 | } 259 | }, 260 | "@types/node": { 261 | "version": "18.14.6", 262 | "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.6.tgz", 263 | "integrity": "sha512-93+VvleD3mXwlLI/xASjw0FzKcwzl3OdTCzm1LaRfqgS21gfFtK3zDXM5Op9TeeMsJVOaJ2VRDpT9q4Y3d0AvA==" 264 | }, 265 | "asynckit": { 266 | "version": "0.4.0", 267 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 268 | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" 269 | }, 270 | "axios": { 271 | "version": "0.26.1", 272 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", 273 | "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", 274 | "requires": { 275 | "follow-redirects": "^1.14.8" 276 | } 277 | }, 278 | "colors": { 279 | "version": "1.4.0", 280 | "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", 281 | "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==" 282 | }, 283 | "combined-stream": { 284 | "version": "1.0.8", 285 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 286 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 287 | "requires": { 288 | "delayed-stream": "~1.0.0" 289 | } 290 | }, 291 | "core-util-is": { 292 | "version": "1.0.3", 293 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", 294 | "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" 295 | }, 296 | "delayed-stream": { 297 | "version": "1.0.0", 298 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 299 | "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" 300 | }, 301 | "duplexer2": { 302 | "version": "0.1.4", 303 | "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", 304 | "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", 305 | "requires": { 306 | "readable-stream": "^2.0.2" 307 | } 308 | }, 309 | "follow-redirects": { 310 | "version": "1.15.2", 311 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", 312 | "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" 313 | }, 314 | "form-data": { 315 | "version": "4.0.0", 316 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 317 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 318 | "requires": { 319 | "asynckit": "^0.4.0", 320 | "combined-stream": "^1.0.8", 321 | "mime-types": "^2.1.12" 322 | } 323 | }, 324 | "inherits": { 325 | "version": "2.0.4", 326 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 327 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 328 | }, 329 | "isarray": { 330 | "version": "1.0.0", 331 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 332 | "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" 333 | }, 334 | "mime-db": { 335 | "version": "1.52.0", 336 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 337 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" 338 | }, 339 | "mime-types": { 340 | "version": "2.1.35", 341 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 342 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 343 | "requires": { 344 | "mime-db": "1.52.0" 345 | } 346 | }, 347 | "multipipe": { 348 | "version": "4.0.0", 349 | "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-4.0.0.tgz", 350 | "integrity": "sha512-jzcEAzFXoWwWwUbvHCNPwBlTz3WCWe/jPcXSmTfbo/VjRwRTfvLZ/bdvtiTdqCe8d4otCSsPCbhGYcX+eggpKQ==", 351 | "requires": { 352 | "duplexer2": "^0.1.2", 353 | "object-assign": "^4.1.0" 354 | } 355 | }, 356 | "object-assign": { 357 | "version": "4.1.1", 358 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 359 | "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" 360 | }, 361 | "openai": { 362 | "version": "3.2.1", 363 | "resolved": "https://registry.npmjs.org/openai/-/openai-3.2.1.tgz", 364 | "integrity": "sha512-762C9BNlJPbjjlWZi4WYK9iM2tAVAv0uUp1UmI34vb0CN5T2mjB/qM6RYBmNKMh/dN9fC+bxqPwWJZUTWW052A==", 365 | "requires": { 366 | "axios": "^0.26.0", 367 | "form-data": "^4.0.0" 368 | } 369 | }, 370 | "process-nextick-args": { 371 | "version": "2.0.1", 372 | "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", 373 | "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" 374 | }, 375 | "readable-stream": { 376 | "version": "2.3.8", 377 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", 378 | "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", 379 | "requires": { 380 | "core-util-is": "~1.0.0", 381 | "inherits": "~2.0.3", 382 | "isarray": "~1.0.0", 383 | "process-nextick-args": "~2.0.0", 384 | "safe-buffer": "~5.1.1", 385 | "string_decoder": "~1.1.1", 386 | "util-deprecate": "~1.0.1" 387 | } 388 | }, 389 | "safe-buffer": { 390 | "version": "5.1.2", 391 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 392 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 393 | }, 394 | "split2": { 395 | "version": "3.2.2", 396 | "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", 397 | "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", 398 | "requires": { 399 | "readable-stream": "^3.0.0" 400 | }, 401 | "dependencies": { 402 | "readable-stream": { 403 | "version": "3.6.1", 404 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", 405 | "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", 406 | "requires": { 407 | "inherits": "^2.0.3", 408 | "string_decoder": "^1.1.1", 409 | "util-deprecate": "^1.0.1" 410 | } 411 | } 412 | } 413 | }, 414 | "string_decoder": { 415 | "version": "1.1.1", 416 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", 417 | "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", 418 | "requires": { 419 | "safe-buffer": "~5.1.0" 420 | } 421 | }, 422 | "strip-bom": { 423 | "version": "4.0.0", 424 | "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", 425 | "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==" 426 | }, 427 | "subtitle": { 428 | "version": "4.2.1", 429 | "resolved": "https://registry.npmjs.org/subtitle/-/subtitle-4.2.1.tgz", 430 | "integrity": "sha512-ohV7DcQAYjoO8SDTZHaD912g6K+JktbLERlkZyuoNWSXboOOdIvuriF4fZC0T6lbVeiqLfR8mmw3CxIJ5+UTuw==", 431 | "requires": { 432 | "@types/multipipe": "^3.0.0", 433 | "multipipe": "^4.0.0", 434 | "split2": "^3.2.2", 435 | "strip-bom": "^4.0.0" 436 | } 437 | }, 438 | "util-deprecate": { 439 | "version": "1.0.2", 440 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 441 | "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" 442 | } 443 | } 444 | } 445 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "subtitle-translator", 3 | "type": "module", 4 | "version": "1.0.0", 5 | "description": "Translate subtitle using ChatGPT", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/gnehs/subtitle-translator.git" 13 | }, 14 | "author": "", 15 | "license": "ISC", 16 | "bugs": { 17 | "url": "https://github.com/gnehs/subtitle-translator/issues" 18 | }, 19 | "homepage": "https://github.com/gnehs/subtitle-translator#readme", 20 | "dependencies": { 21 | "colors": "^1.4.0", 22 | "openai": "^3.2.1", 23 | "subtitle": "^4.2.1" 24 | } 25 | } -------------------------------------------------------------------------------- /res/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnehs/subtitle-translator/954e16507a079c708b607f395f05f670c9d87179/res/.gitkeep -------------------------------------------------------------------------------- /src/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnehs/subtitle-translator/954e16507a079c708b607f395f05f670c9d87179/src/.gitkeep --------------------------------------------------------------------------------