deepgram-captions


Namedeepgram-captions JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://github.com/deepgram/deepgram-python-captions
SummaryA Python package for generating captions.
upload_time2024-02-07 21:11:00
maintainer
docs_urlNone
authorDeepgram
requires_python
license
keywords deepgram captions srt webvtt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Deepgram Python Captions

[![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)

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.

The 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.

## Installation

```bash
pip install deepgram-captions
```

## How it works

The 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.

You 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.)

## WebVTT from Deepgram Transcriptions

```python
from deepgram_captions import DeepgramConverter, webvtt

transcription = DeepgramConverter(dg_response)
captions = webvtt(transcription)
```

## SRT from Deepgram Transcriptions

```py
from deepgram_captions import DeepgramConverter, srt

transcription = DeepgramConverter(dg_response)
captions = srt(transcription)
```

### Line length

Add an optional integer parameter to set the line length of the caption.

```py
line_length = 10

deepgram = DeepgramConverter(dg_speakers)
captions = webvtt(deepgram, line_length)
```

## Other Converters

### Whisper

Open 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:

#### Deepgram's Whisper Cloud

Use 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.

```py
from deepgram_captions import DeepgramConverter, srt

transcription = DeepgramConverter(whisper_response)
captions = srt(transcription)
```

#### Whisper Timestamped

[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).

```py
from deepgram_captions import WhisperTimestampedConverter, webvtt

transcription = WhisperTimestampedConverter(whisper_response)
captions = webvtt(transcription)
```

### Assembly AI

AssemblyAI is another popular speech-to-text API.

```py
from deepgram_captions import AssemblyAIConverter, webvtt

transcription = AssemblyAIConverter(assembly_response)
captions = webvtt(transcription)
```

## Output

### Output WebVTT

When transcribing https://dpgr.am/spacewalk.wav, and running it through our library, this is the WebVTT output.

```py
from deepgram_captions.converters import DeepgramConverter
from deepgram_captions.webvtt import webvtt

transcription = DeepgramConverter(dg_response)
captions = webvtt(transcription)
print(captions)
```

This is the result:

```text
WEBVTT

NOTE
Transcription provided by Deepgram
Request Id: 686278aa-d315-4aeb-b2a9-713615544366
Created: 2023-10-27T15:35:56.637Z
Duration: 25.933313
Channels: 1

00:00:00.080 --> 00:00:03.220
Yeah. As as much as, it's worth celebrating,

00:00:04.400 --> 00:00:05.779
the first, spacewalk,

00:00:06.319 --> 00:00:07.859
with an all female team,

00:00:08.475 --> 00:00:10.715
I think many of us are looking forward

00:00:10.715 --> 00:00:13.215
to it just being normal and

00:00:13.835 --> 00:00:16.480
I think if it signifies anything, It is

00:00:16.779 --> 00:00:18.700
to honor the the women who came before

00:00:18.700 --> 00:00:21.680
us who, were skilled and qualified,

00:00:22.300 --> 00:00:24.779
and didn't get the same opportunities that we

00:00:24.779 --> 00:00:25.439
have today.
```

## Output SRT

When transcribing https://dpgr.am/spacewalk.wav, and running it through our library, this is the SRT output.

```py
from deepgram_captions import DeepgramConverter, srt

transcription = DeepgramConverter(dg_response)
captions = srt(transcription)
print(captions)
```

This is the result:

```text
1
00:00:00,080 --> 00:00:03,220
Yeah. As as much as, it's worth celebrating,

2
00:00:04,400 --> 00:00:07,859
the first, spacewalk, with an all female team,

3
00:00:08,475 --> 00:00:10,715
I think many of us are looking forward

4
00:00:10,715 --> 00:00:14,235
to it just being normal and I think

5
00:00:14,235 --> 00:00:17,340
if it signifies anything, It is to honor

6
00:00:17,340 --> 00:00:19,820
the the women who came before us who,

7
00:00:20,140 --> 00:00:23,580
were skilled and qualified, and didn't get the

8
00:00:23,580 --> 00:00:25,439
same opportunities that we have today.
```

## Documentation

You can learn more about the Deepgram API at [developers.deepgram.com](https://developers.deepgram.com/docs).

## Development and Contributing

Interested in contributing? We ❤️ pull requests!

To make sure our community is safe for all, be sure to review and agree to our
[Code of Conduct](./.github/CODE_OF_CONDUCT.md). Then see the
[Contribution](./.github/CONTRIBUTING.md) guidelines for more information.

## Getting Help

We love to hear from you so if you have questions, comments or find a bug in the
project, let us know! You can either:

- [Open an issue in this repository](https://github.com/deepgram/[reponame]/issues/new)
- [Join the Deepgram Github Discussions Community](https://github.com/orgs/deepgram/discussions)
- [Join the Deepgram Discord Community](https://discord.gg/xWRaCDBtW4)

[license]: LICENSE.txt

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/deepgram/deepgram-python-captions",
    "name": "deepgram-captions",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "deepgram,captions,srt,webvtt",
    "author": "Deepgram",
    "author_email": "devrel@deepgram.com",
    "download_url": "https://files.pythonhosted.org/packages/b8/23/6d8aeb10c675b8f30697f0239d8e63b0cc5dc3f861dc7070a3d3eb4ecf12/deepgram-captions-1.2.0.tar.gz",
    "platform": null,
    "description": "# 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 --> 00:00:03.220\nYeah. As as much as, it's worth celebrating,\n\n00:00:04.400 --> 00:00:05.779\nthe first, spacewalk,\n\n00:00:06.319 --> 00:00:07.859\nwith an all female team,\n\n00:00:08.475 --> 00:00:10.715\nI think many of us are looking forward\n\n00:00:10.715 --> 00:00:13.215\nto it just being normal and\n\n00:00:13.835 --> 00:00:16.480\nI think if it signifies anything, It is\n\n00:00:16.779 --> 00:00:18.700\nto honor the the women who came before\n\n00:00:18.700 --> 00:00:21.680\nus who, were skilled and qualified,\n\n00:00:22.300 --> 00:00:24.779\nand didn't get the same opportunities that we\n\n00:00:24.779 --> 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 --> 00:00:03,220\nYeah. As as much as, it's worth celebrating,\n\n2\n00:00:04,400 --> 00:00:07,859\nthe first, spacewalk, with an all female team,\n\n3\n00:00:08,475 --> 00:00:10,715\nI think many of us are looking forward\n\n4\n00:00:10,715 --> 00:00:14,235\nto it just being normal and I think\n\n5\n00:00:14,235 --> 00:00:17,340\nif it signifies anything, It is to honor\n\n6\n00:00:17,340 --> 00:00:19,820\nthe the women who came before us who,\n\n7\n00:00:20,140 --> 00:00:23,580\nwere skilled and qualified, and didn't get the\n\n8\n00:00:23,580 --> 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 \u2764\ufe0f 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",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python package for generating captions.",
    "version": "1.2.0",
    "project_urls": {
        "Homepage": "https://github.com/deepgram/deepgram-python-captions"
    },
    "split_keywords": [
        "deepgram",
        "captions",
        "srt",
        "webvtt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f195795fdd6c99d2e6dfd2478402c25b1087b5129bc970124ce2e4b0571a8c3d",
                "md5": "b8bdb53f61f5f789d38ffe992a9018fc",
                "sha256": "fb8c26586fc7f15160644d45f9c5fefec4b1caa375df01d2320599245e03095a"
            },
            "downloads": -1,
            "filename": "deepgram_captions-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b8bdb53f61f5f789d38ffe992a9018fc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7643,
            "upload_time": "2024-02-07T21:10:59",
            "upload_time_iso_8601": "2024-02-07T21:10:59.764206Z",
            "url": "https://files.pythonhosted.org/packages/f1/95/795fdd6c99d2e6dfd2478402c25b1087b5129bc970124ce2e4b0571a8c3d/deepgram_captions-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b8236d8aeb10c675b8f30697f0239d8e63b0cc5dc3f861dc7070a3d3eb4ecf12",
                "md5": "e1a8ed45b36c33bdbdda506dcb44f9c3",
                "sha256": "2d041b5c84a4438d7b7a633780fee92ecff3c7880721737c8244acd9eb5a7a53"
            },
            "downloads": -1,
            "filename": "deepgram-captions-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e1a8ed45b36c33bdbdda506dcb44f9c3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8297,
            "upload_time": "2024-02-07T21:11:00",
            "upload_time_iso_8601": "2024-02-07T21:11:00.917399Z",
            "url": "https://files.pythonhosted.org/packages/b8/23/6d8aeb10c675b8f30697f0239d8e63b0cc5dc3f861dc7070a3d3eb4ecf12/deepgram-captions-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-07 21:11:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "deepgram",
    "github_project": "deepgram-python-captions",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "deepgram-captions"
}
        
Elapsed time: 0.20265s