https://github.com/yochem/cap
🧢 Convert time-tagged transcripts to good captions
https://github.com/yochem/cap
Last synced: 11 months ago
JSON representation
🧢 Convert time-tagged transcripts to good captions
- Host: GitHub
- URL: https://github.com/yochem/cap
- Owner: yochem
- Created: 2020-06-02T12:42:22.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-07T22:35:33.000Z (almost 6 years ago)
- Last Synced: 2025-06-10T00:43:59.456Z (about 1 year ago)
- Language: Python
- Homepage: https://yochem.github.io/cap/
- Size: 489 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cap - AI powered subtitling
This project converts a JSON speech-to-text file to a fully functional SRT
subtitle file. This SRT file consists of caption groups with if needed, line
breaks according to the [subtitle guidelines of the
BBC](https://bbc.github.io/subtitle-guidelines/#Break-at-natural-points).
## Table of Contents
- [Features](#features)
- [Badges](#badges)
- [Preview](#preview)
- [Installation](#installation)
- [How to run](#how_to_run)
- [Overview functionality](#overview_functionality)
- [Support](#support)
## Features
This project mainly generates proper formatted caption groups given a
transcript with word-timing. It implements the following rules from the BBC
guide mentioned above:
- Part-of-Speech tags
- Punctuation
- Gaps in speech
- Character limit (< 84)
- Line limit (< 42)
- Characters per second
- Adding line breaks
- Complex verb phrases
## Badges



## Preview

## Installation
1. [Clone](https://bit.ly/2BcAdRs) this repository.
2. Install the package:
```shell
$ pip3 install -e cap
```
## How to use
In your shell, run the following:
```shell
$ cap --output
```
For more options, run `$ cap -h`.
Or use this module in Python:
```python
>>> import cap
>>> subs = cap.group('asr/sample01.asrOutput.json', 'srt-file.srt')
>>>
>>> # let's see the first caption group in Python:
>>> print(*subs[0], sep='\n')
Word(text='thanks', start=0.24, end=0.51, weight=5)
Word(text='to', start=0.51, end=0.6, weight=5)
Word(text='last', start=0.6, end=0.86, weight=5)
Word(text='past', start=0.86, end=1.13, weight=5.64)
Word(text='for\n', start=1.13, end=1.2, weight=5.96)
Word(text='sponsoring', start=1.2, end=1.63, weight=5.96)
Word(text='a', start=1.63, end=1.69, weight=5.34)
Word(text='portion', start=1.69, end=2.02, weight=5)
Word(text='of', start=2.02, end=2.12, weight=4.6)
Word(text='this', start=2.12, end=2.31, weight=4.7)
Word(text='video', start=2.31, end=2.75, weight=5)
Punc(text='.', start=2.75, end=2.75, weight=5.95)
>>>
>>> # and let's see the first caption group in the srt file:
>>> with open('srt-file.srt', 'r') as f:
>>> content = f.read().split('\n\n')[0]
>>> print(content)
1
00:00:00,240 --> 00:00:02,750
thanks to last past for
sponsoring a portion of this video.
```
## Development
Documentation can be found at [Github Pages](yochem.github.io/caps/).
To install the needed packages for development, run this:
```shell
$ pip3 install -e cap[dev]
```
Also make sure [editorconfig](editorconfig.org/) is installed in your editor
of choice.
When pushing code, first run `$ make check` to lint your code and `$ make doc`
to create the docs.
## Support
Found a bug? Got a question? Please report it using Github
[issues](https://github.com/yochem/effect.ai/issues)!