Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Automatically synchronize subtitles with audio using machine learning
| Date | Stars |
|---|---|
| 2026-07-31 | 461 |
| 2026-08-06 | 461 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# Automatic subtitle synchronization tool
[](https://pypi.python.org/pypi/autosubsync)
Did you know that hundreds of movies, especially from the 1950s and '60s,
are now in public domain and available online? Great! Let's download
_Plan 9 from Outer Space_. As a non-native English speaker, I prefer watching
movies with subtitles, which can also be found online for free. However, sometimes
there is a problem: the subtitles are not in sync with the movie.
But fear not. This tool can resynchronize the subtitles without any human input.
A correction for both shift and playing speed can be found automatically...
[using "AI & machine learning"](#methods)
## Installation
### macOS / OSX
Prerequisites: Install [Homebrew](https://brew.sh/) and [pip](https://stackoverflow.com/questions/17271319/how-do-i-install-pip-on-macos-or-os-x). Then install FFmpeg and this package
```
brew install ffmpeg
pip install autosubsync
```
### Linux (Debian & Ubuntu)
Make sure you have Pip, e.g., `sudo apt-get install python-pip`.
Then install [FFmpeg](https://www.ffmpeg.org/) and this package
```
sudo apt install ffmpeg
sudo apt install libsndfile1 # sometimes optional
sudo pip install autosubsync
```
The `libsndfile1` is sometimes but not always needed due to https://github.com/bastibe/python-soundfile/issues/258.
## Usage
```
autosubsync [input movie] [input subtitles] [output subs]
# for example
autosubsync plan-9-from-outer-space.avi \
plan-9-out-of-sync-subs.srt \
plan-9-subtitles-synced.srt
```
See `autosubsync --help` for more details.
## Features
* Automatic speed and shift correction
* Typical synchronization accuracy ~0.15 seconds (see [performance](#performance))
* Wide video format support through [ffmpeg](https://www.ffmpeg.org/)
* Supports all reasonably encoded SRT files in any language
* Should work with any language in the audio (only tested with a few though)
* Quality-of-fit metric for checking sync success
* Python API. Example (save as `batch_sync.py`):
```python
"Batch synchronize video files in a folder: python batch_sync.py /path/to/folder"
import autosubsync
import glob, os, sys
if __name__ == '__main__':
for video_file in glob.glob(os.path.join(sys.argv[1], '*.mp4')):
base = video_file.rpartition('.')[0]
srt_file = base + '.srt'
synced_srt_file = base + '_synced.srt'
# see help(autosubsync.synchronize) for more details
autosubsync.synchronize(video_file, srt_file, synced_srt_file)
```
## Development
### Training the model
1. Collect a bunch of well-synchronized video and subtitle files and put them
in a file called `training/sources.csv` (see `training/sources.csv.example`)
2. Run (and see) `train_and_test.sh`. This
* populates the `training/data` folder
* creates `trained-model.bin`
* runs cross-validation
### Synchronization (predict)
Assumes trained model is available as `trained-model.bin`
python3 autosubsync/main.py input-video-file input-subs.srt synced-subs.srt
### Build and distribution
* Create virtualenv: `python3 -m venv venvs/test-python3`
* Activate venv: `source venvs/test-python3/bin/activate`
* `pip install -e .`
* `pip install wheel`
* `python setup.py bdist_wheel`
## Methods
The basic idea is to first detect speech on the audio track, that is, for each
point in time, _t_, in the film, to estimate if speech is heard. The method
[described below](#speech-detection) produces this estimate as a probability
of speech _p(t)_.
Another input to the program is the unsynchronized subtitle file containing the
timestamps of the actual subtitle intervals.
Synchronization is done by finding a time transformation _t_ → _f(t)_ that
makes _s(f(t))_, the synchronized subtitles, best [match](#loss-function),
_p(t)_, the detected speech. Here _s(t)_ is the (unsynchronized) subtitle
indicator function whose value is 1 if aExcerpt of 8,849 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:8096a30fa4b8ac47, llm:README description: 'Automatically synchronize subtitles with audio using machine learning'; topics include 'machine-learning', 'ffmpeg', 'command-line-tool'; features mention automatic speed and shift correction and quality-of-fit metric.
matched fp:8096a30fa4b8ac47, llm:README description: 'Automatically synchronize subtitles with audio using machine learning'; topics include 'machine-learning', 'ffmpeg', 'command-line-tool'; features mention automatic speed and shift correction and quality-of-fit metric.