{"id":13907029,"url":"https://github.com/benwiley4000/vtt-translate","last_synced_at":"2025-04-23T07:31:30.948Z","repository":{"id":57394300,"uuid":"174056997","full_name":"benwiley4000/vtt-translate","owner":"benwiley4000","description":"🔇 🉑️ Google Translate your .vtt subtitle files into other languages","archived":false,"fork":false,"pushed_at":"2022-01-21T15:19:12.000Z","size":20,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T10:12:03.953Z","etag":null,"topics":["captions","subtitles","translate","webvtt"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benwiley4000.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-06T02:36:05.000Z","updated_at":"2024-08-03T19:26:29.000Z","dependencies_parsed_at":"2022-09-19T10:30:39.166Z","dependency_job_id":null,"html_url":"https://github.com/benwiley4000/vtt-translate","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwiley4000%2Fvtt-translate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwiley4000%2Fvtt-translate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwiley4000%2Fvtt-translate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwiley4000%2Fvtt-translate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benwiley4000","download_url":"https://codeload.github.com/benwiley4000/vtt-translate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249984653,"owners_count":21356089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["captions","subtitles","translate","webvtt"],"created_at":"2024-08-06T23:01:46.558Z","updated_at":"2025-04-23T07:31:30.590Z","avatar_url":"https://github.com/benwiley4000.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# vtt-translate\n\nNot exactly the best idea...\n\n...but you can use this to Google Translate your .vtt subtitle files into other languages!\n\nRequires [Node.js](https://nodejs.org) 7.10.1 or later.\n\n### disclaimer\n\nI really want to emphasize that this isn't a great way to produce a translation for your video/audio content. The best way is to hire a professional translator. If you have a budget for producing your content, and you need a translation, please allocate some of that budget for paying a translator.\n\nIf you're working on a volunteer-based project with no budget, or you just need some test data, this can work well enough for you.\n\nKeep in mind that translations are done in fixed sized batches of a certain number of lines, so there probably will be occasional translation errors specifically due to context being cut off from the beginning or end of a batch of text. \n\n## command line\n\n### install\n\n```console\nnpm install --global vtt-translate\n```\n\n### use\n\n```console\n$ vtt-translate \nInput VTT filename: ./vtt/transcript_en.vtt\nSource language code: en\nDestination language code: fr\nGoogle Translate API key (https://cloud.google.com/translate/): [Paste your API key here]\nTranslating...\nTranslation complete!\nDestination VTT filename: ./vtt/transcript_fr.vtt\n$\n```\nSee the [Node API](#node-api) description for explanation of the command line inputs.\n\nNote that API limits apply... if you fill your daily quota, a restore file will be saved so you can continue the next day without losing your progress:\n\n```console\n$ vtt-translate \nInput VTT filename: ./vtt/transcript_en.vtt\nSource language code: en\nDestination language code: fr\nGoogle Translate API key (https://cloud.google.com/translate/): [Paste your API key here]\nTranslating...\n{ code: 403,\n  message: 'User Rate Limit Exceeded',\n  errors: \n   [ { message: 'User Rate Limit Exceeded',\n       domain: 'usageLimits',\n       reason: 'userRateLimitExceeded' } ],\n  translatedCues: \n   [ ... ] }\n\nSaving temp file so we can resume later where we left off...\nProgress: 2688 of 2767 cues (2688 newly translated)\n$\n```\n\nDon't remove this temp file! Otherwise you'll have to start over from scratch later.\n\nOnce the download completes, the temp file will be deleted automatically.\n\n## Node API\n\n### install\n\n```console\nnpm install --save vtt-translate\n```\n\n### use\n\nThis API example is functionally identical to the earlier command line example.\n\n```js\nconst { getTranslatedVttForPathname } = require('vtt-translate');\nconst fs = require('fs');\n\nconst pathname = './vtt/transcript_en.vtt';\nconst apiKey = '[Paste your API key here]';\nconst source = 'en';\nconst target = 'fr';\n\ngetTranslatedVttForPathname(pathname, apiKey, { source, target })\n  .then(vttContent =\u003e {\n    fs.writeFile('./vtt/transcript_fr.vtt', vttContent, err =\u003e {\n      if (err) {\n        console.error(err);\n      }\n    });\n  })\n  .catch(err =\u003e {\n    console.error(err);\n  });\n```\n\n### API\n\n#### `getTranslatedVttForPathname(pathname, apiKey, params)`\n\n#### Arguments\n* `pathname`: The filesystem pathname for the source vtt file.\n* `apiKey`: A valid Google Cloud Translation API key\n* `params.source`: A [language code supported by Google's Neural Machine Translation Model](https://cloud.google.com/translate/docs/languages#languages-nmt), corresponding to the language of the source text (e.g. `'en'`)\n* `params.target` A language code corresponding to the translation target language\n* `params.restoredCuesPathname`: A pathname pointing to a JSON file saved with a backup of previously translated cues (see error handling)\n\n#### Returns\nA `Promise` which resolves with the full text of the translated vtt file (as a string)\n\n#### Error handling\nIf you `.catch` an error and the error has a `translatedCues` property, you can save that object to a json file and restore it later with `params.restoredCuesPathname`. This allows downloading a translation across multiple days if your API request quota is too small to download the translation in one day.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenwiley4000%2Fvtt-translate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenwiley4000%2Fvtt-translate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenwiley4000%2Fvtt-translate/lists"}