{"id":21495621,"url":"https://github.com/deepgram/deepgram-js-captions","last_synced_at":"2025-07-15T19:31:59.391Z","repository":{"id":203999210,"uuid":"710788505","full_name":"deepgram/deepgram-js-captions","owner":"deepgram","description":"This package is the JavaScript implementation of Deepgram's WebVTT and SRT formatting. Given a transcription, this package can return a valid string to store as WebVTT or SRT caption files.","archived":false,"fork":false,"pushed_at":"2024-08-30T23:01:11.000Z","size":211,"stargazers_count":11,"open_issues_count":4,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-15T20:49:09.823Z","etag":null,"topics":["asr","audio","closed-captions","deepgram","ffmpeg","javascript","sdk","speech","speech-to-text","srt","stt","subtitles","transcription","typescript","webvtt","youtube"],"latest_commit_sha":null,"homepage":"https://github.com/deepgram/deepgram-js-captions","language":"TypeScript","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/deepgram.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-27T12:49:10.000Z","updated_at":"2024-09-19T18:39:54.000Z","dependencies_parsed_at":"2023-10-31T10:38:42.385Z","dependency_job_id":null,"html_url":"https://github.com/deepgram/deepgram-js-captions","commit_stats":null,"previous_names":["deepgram/deepgram-node-captions","deepgram/deepgram-js-captions"],"tags_count":4,"template":false,"template_full_name":"deepgram/oss-repo-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-js-captions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-js-captions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-js-captions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-js-captions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepgram","download_url":"https://codeload.github.com/deepgram/deepgram-js-captions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226064538,"owners_count":17568036,"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":["asr","audio","closed-captions","deepgram","ffmpeg","javascript","sdk","speech","speech-to-text","srt","stt","subtitles","transcription","typescript","webvtt","youtube"],"created_at":"2024-11-23T16:12:29.978Z","updated_at":"2024-11-23T16:12:30.655Z","avatar_url":"https://github.com/deepgram.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deepgram Captions\n\n [![Discord](https://dcbadge.vercel.app/api/server/xWRaCDBtW4?style=flat)](https://discord.gg/xWRaCDBtW4) [![npm version](https://badge.fury.io/js/@deepgram%2Fcaptions.svg)](https://badge.fury.io/js/@deepgram%2Fcaptions)\n\nThis package is the JavaScript implementation of Deepgram's WebVTT and SRT formatting. Given a transcription, this package can return a valid string to store as WebVTT or SRT caption files.\n\n\u003e Works with ANY transcription format.\n\n## Installation\n\n```bash\nnpm install @deepgram/captions\n# - or -\n# yarn add @deepgram/captions\n```\n\n## WebVTT from Deepgram Transcriptions\n\n```ts\nimport { webvtt } from \"@deepgram/captions\";\n\nconst result = webvtt(deepgram_transcription_result);\n```\n\n## SRT from Deepgram Transcriptions\n\n```ts\nimport { srt } from \"@deepgram/captions\";\n\nconst result = srt(deepgram_transcription_result);\n```\n\n## Converters\n\nThis package has been built to convert any transcription format. You only need to provide a `converter` class to provide the formatters with the correct data.\n\n### Example Converter\n\nA generic converter would look like this:\n\n```ts\nimport { chunkArray, WordBase, IConverter } from \"@deepgram/captions\";\n\nexport class GenericConverter implements IConverter {\n  constructor(public transcriptionData: any) {}\n\n  getLines(lineLength: number = 8): WordBase[][] {\n    const results = this.transcriptionData;\n    let content: WordBase[][] = [];\n\n    results.paragraphs.forEach((paragraph) =\u003e {\n      if (paragraph.words.length \u003e lineLength) {\n        content.push(...chunkArray(paragraph.words, lineLength));\n      } else {\n        content.push(paragraph.words);\n      }\n    });\n\n    return content;\n  }\n}\n```\n\nIt requires that `getLines` return the following data structure:\n\n```ts\n// const transcriptionData: WordBase[][] = [\nconst transcriptionData = [\n  [\n    {\n      word: string;\n      start: number;\n      end: number;\n      punctuated_word: string; // optional\n    }\n  ]\n]\n```\n\nUsing your converter will look like this:\n\n```ts\nimport { srt } from \"@deepgram/captions\";\n\nconst result = srt(new GenericConverter(transcription_result));\n```\n\n### Included Converters\n\n#### Assembly AI\n\n```ts\nimport { webvtt, AssemblyAiConverter } from \"@deepgram/captions\";\n\nconst result = webvtt(new AssemblyAiConverter(assembly_result));\n```\n\n## Output WebVTT\n\nWhen transcribing https://dpgr.am/spacewalk.wav, and running it through our library, this is the WebVTT output.\n\n```ts\nimport { webvtt } from \"@deepgram/captions\";\n\nconst result = webvtt(deepgram_transcription_result);\n\nconsole.log(result);\n```\n\nThis is the result:\n\n```text\nWEBVTT\n\nNOTE\nTranscription provided by Deepgram\nRequest Id: 686278aa-d315-4aeb-b2a9-713615544366\nCreated: 2023-10-27T15:35:56.637Z\nDuration: 25.933313\nChannels: 1\n\n00:00:00.080 --\u003e 00:00:03.220\nYeah. As as much as, it's worth celebrating,\n\n00:00:04.400 --\u003e 00:00:05.779\nthe first, spacewalk,\n\n00:00:06.319 --\u003e 00:00:07.859\nwith an all female team,\n\n00:00:08.475 --\u003e 00:00:10.715\nI think many of us are looking forward\n\n00:00:10.715 --\u003e 00:00:13.215\nto it just being normal and\n\n00:00:13.835 --\u003e 00:00:16.480\nI think if it signifies anything, It is\n\n00:00:16.779 --\u003e 00:00:18.700\nto honor the the women who came before\n\n00:00:18.700 --\u003e 00:00:21.680\nus who, were skilled and qualified,\n\n00:00:22.300 --\u003e 00:00:24.779\nand didn't get the same opportunities that we\n\n00:00:24.779 --\u003e 00:00:25.439\nhave today.\n```\n\n## Output SRT\n\nWhen transcribing https://dpgr.am/spacewalk.wav, and running it through our library, this is the SRT output.\n\n```ts\nimport { srt } from \"@deepgram/captions\";\n\nconst result = srt(deepgram_transcription_result);\n\nconsole.log(result);\n```\n\nThis is the result:\n\n```text\n1\n00:00:00,080 --\u003e 00:00:03,220\nYeah. As as much as, it's worth celebrating,\n\n2\n00:00:04,400 --\u003e 00:00:07,859\nthe first, spacewalk, with an all female team,\n\n3\n00:00:08,475 --\u003e 00:00:10,715\nI think many of us are looking forward\n\n4\n00:00:10,715 --\u003e 00:00:14,235\nto it just being normal and I think\n\n5\n00:00:14,235 --\u003e 00:00:17,340\nif it signifies anything, It is to honor\n\n6\n00:00:17,340 --\u003e 00:00:19,820\nthe the women who came before us who,\n\n7\n00:00:20,140 --\u003e 00:00:23,580\nwere skilled and qualified, and didn't get the\n\n8\n00:00:23,580 --\u003e 00:00:25,439\nsame opportunities that we have today.\n```\n\n## Documentation\n\nYou can learn more about the Deepgram API at [developers.deepgram.com](https://developers.deepgram.com/docs).\n\n## Development and Contributing\n\nInterested in contributing? We ❤️ pull requests!\n\nTo make sure our community is safe for all, be sure to review and agree to our\n[Code of Conduct](./.github/CODE_OF_CONDUCT.md). Then see the\n[Contribution](./.github/CONTRIBUTING.md) guidelines for more information.\n\n## Getting Help\n\nWe love to hear from you so if you have questions, comments or find a bug in the\nproject, let us know! You can either:\n\n- [Open an issue in this repository](https://github.com/deepgram/[reponame]/issues/new)\n- [Join the Deepgram Github Discussions Community](https://github.com/orgs/deepgram/discussions)\n- [Join the Deepgram Discord Community](https://discord.gg/xWRaCDBtW4)\n\n[license]: LICENSE.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepgram%2Fdeepgram-js-captions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepgram%2Fdeepgram-js-captions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepgram%2Fdeepgram-js-captions/lists"}