{"id":21495641,"url":"https://github.com/deepgram/deepgram-python-captions","last_synced_at":"2025-07-08T07:08:13.623Z","repository":{"id":204913023,"uuid":"712954909","full_name":"deepgram/deepgram-python-captions","owner":"deepgram","description":"This package is the Python 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-10-07T15:51:04.000Z","size":79,"stargazers_count":18,"open_issues_count":3,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-13T12:52:57.796Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-11-01T14:47:34.000Z","updated_at":"2024-10-09T22:18:11.000Z","dependencies_parsed_at":"2024-02-07T22:26:32.735Z","dependency_job_id":"b53f7c50-aa07-4521-a9a8-4afb44aba9b8","html_url":"https://github.com/deepgram/deepgram-python-captions","commit_stats":null,"previous_names":["deepgram/deepgram-python-captions"],"tags_count":9,"template":false,"template_full_name":"deepgram/oss-repo-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-python-captions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-python-captions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-python-captions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-python-captions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepgram","download_url":"https://codeload.github.com/deepgram/deepgram-python-captions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226064537,"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":[],"created_at":"2024-11-23T16:12:39.098Z","updated_at":"2024-11-23T16:12:39.635Z","avatar_url":"https://github.com/deepgram.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deepgram Python Captions\n\n[![Discord](https://dcbadge.vercel.app/api/server/xWRaCDBtW4?style=flat)](https://discord.gg/xWRaCDBtW4) [![PyPI version](https://badge.fury.io/py/deepgram-captions.svg)](https://badge.fury.io/py/deepgram-captions)\n\nThis package is the Python 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\nThe package is not dependent on Deepgram, but it is expected that you will provide a JSON response from a transcription request from either Deepgram or one of the other supported speech-to-text APIs.\n\n## Installation\n\n```bash\npip install deepgram-captions\n```\n\n## How it works\n\nThe converter takes in a JSON object response (see examples in the `./test` folder.) Depending on which API you use, the converter will turn that into a shape that can be handled by the `webvtt` and `srt` scripts.\n\nYou provide the JSON object; then select the converter needed such as `DeepgramConverter`, `WhisperTimestampedConverter`, `AssemblyAIConverter` and so on. (If the API you want to use is not supported, please reach out to `devrel@deepgram.com` and we will do our best to add it.)\n\n## WebVTT from Deepgram Transcriptions\n\n```python\nfrom deepgram_captions import DeepgramConverter, webvtt\n\ntranscription = DeepgramConverter(dg_response)\ncaptions = webvtt(transcription)\n```\n\n## SRT from Deepgram Transcriptions\n\n```py\nfrom deepgram_captions import DeepgramConverter, srt\n\ntranscription = DeepgramConverter(dg_response)\ncaptions = srt(transcription)\n```\n\n### Line length\n\nAdd an optional integer parameter to set the line length of the caption.\n\n```py\nline_length = 10\n\ndeepgram = DeepgramConverter(dg_speakers)\ncaptions = webvtt(deepgram, line_length)\n```\n\n## Other Converters\n\n### Whisper\n\nOpen AI's Whisper (through their API) does not provide timestamps, so a JSON response directly from OpenAI cannot be used with this package. However, there are a couple other options you can try:\n\n#### Deepgram's Whisper Cloud\n\nUse Deepgram's fully hosted Whisper Cloud, which gives you Whisper transcriptions along with the features that come with Deepgram's API such as timestamps. Use `model=whisper` when you make your request to Deepgram. Then use the `DeepgramConverter` to create the captions.\n\n```py\nfrom deepgram_captions import DeepgramConverter, srt\n\ntranscription = DeepgramConverter(whisper_response)\ncaptions = srt(transcription)\n```\n\n#### Whisper Timestamped\n\n[Whisper Timestamped](https://github.com/linto-ai/whisper-timestamped) adds word-level timestamps to OpenAI's Whisper speech-to-text transcriptions. Word-level timestamps are required for this package to create captions, which is why we have created the captions converter for Whisper Timestamped (and not OpenAI's Whisper).\n\n```py\nfrom deepgram_captions import WhisperTimestampedConverter, webvtt\n\ntranscription = WhisperTimestampedConverter(whisper_response)\ncaptions = webvtt(transcription)\n```\n\n### Assembly AI\n\nAssemblyAI is another popular speech-to-text API.\n\n```py\nfrom deepgram_captions import AssemblyAIConverter, webvtt\n\ntranscription = AssemblyAIConverter(assembly_response)\ncaptions = webvtt(transcription)\n```\n\n## Output\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```py\nfrom deepgram_captions.converters import DeepgramConverter\nfrom deepgram_captions.webvtt import webvtt\n\ntranscription = DeepgramConverter(dg_response)\ncaptions = webvtt(transcription)\nprint(captions)\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```py\nfrom deepgram_captions import DeepgramConverter, srt\n\ntranscription = DeepgramConverter(dg_response)\ncaptions = srt(transcription)\nprint(captions)\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-python-captions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepgram%2Fdeepgram-python-captions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepgram%2Fdeepgram-python-captions/lists"}