Skip to main content

A Python package for generating captions.

Project description

Deepgram Python Captions

Discord PyPI version

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.

Installation

pip install deepgram-captions

WebVTT from Deepgram Transcriptions

from deepgram_captions.converters import DeepgramConverter
from deepgram_captions.webvtt import webvtt

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

SRT from Deepgram Transcriptions

from deepgram_captions.converters import DeepgramConverter
from deepgram_captions.srt import srt

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

Other Converters

Whisper Timestamped

from deepgram_captions.converters import WhisperTimestampedConverter
from deepgram_captions.webvtt import webvtt

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

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

Assembly AI

from deepgram_captions.converters import AssemblyAIConverter
from deepgram_captions.webvtt import webvtt

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

Output WebVTT

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

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:

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.

from deepgram_captions.converters import DeepgramConverter
from deepgram_captions.srt import srt

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

This is the result:

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.

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. Then see the Contribution 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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepgram-captions-1.0.3.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepgram_captions-1.0.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file deepgram-captions-1.0.3.tar.gz.

File metadata

  • Download URL: deepgram-captions-1.0.3.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for deepgram-captions-1.0.3.tar.gz
Algorithm Hash digest
SHA256 c8065c7ddd2770e831f947790d5d790487a7400075f2fc25314a3324e2d80a00
MD5 9190319d57ff0fd7fab012fd0fb17b03
BLAKE2b-256 8f295af894432de68ea223695157549a6a985f30d617bff122af42cd43543854

See more details on using hashes here.

File details

Details for the file deepgram_captions-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for deepgram_captions-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0628c85ab286297bfb2ff0ed582f0691e5d2ba492087b057c23d37d928c2e94a
MD5 212f50ec4ec76eb8851269d2ebcc0bbb
BLAKE2b-256 b2098177504b0a3f8c81ded906ec7aeae67f9bc0fb6e92d692ddb4f28ebe242e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page