• Stars
    star
    160
  • Rank 227,809 (Top 5 %)
  • Language
    TypeScript
  • Created 6 months ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate subtitles for your videos with secure, on-device machine learning models.

gen-subs

This project uses on-device machine learning models to generate subtitles for your videos.

demo.mp4

Features

  • 🔒 Secure and offline - All machine learning models are downloaded and run locally on your device. No data is sent to any server. There is zero dependency on OpenAI or other cloud services.
  • 🌐 Multilingual - Supports a wide variety of languages. Namely,
    Languages
    🇺🇸 English 🇮🇳 Indian English 🇨🇳 Chinese
    🇷🇺 Russian 🇫🇷 French 🇩🇪 German
    🇪🇸 Spanish 🇵🇹 Portuguese/Brazilian 🇬🇷 Greek
    🇹🇷 Turkish 🇻🇳 Vietnamese 🇮🇹 Italian
    🇳🇱 Dutch 🇪🇸 Catalan 🇸🇦 Arabic
    🇮🇷 Farsi 🇵🇭 Filipino 🇺🇦 Ukrainian
    🇰🇿 Kazakh 🇸🇪 Swedish 🇯🇵 Japanese
    🇪🇸 Esperanto 🇮🇳 Hindi 🇨🇿 Czech
    🇵🇱 Polish 🇺🇿 Uzbek 🇰🇷 Korean
    🇫🇷 Breton
  • 🎨 Customizable - Choose from getting just an srt file, having the subtitles burned in to your video, and even embedding the subtitles in your video's metadata. You can also have focus words where the active word is highlighted in a different color.
  • 🎧 Multi-modal - Supports both audio and video files and generates subtitles for each.
  • 📊 Multi-model - Choose from a variety of machine learning models ranging from 40MB to >2GB in size. The larger the model, the more accurate the subtitles, but smaller models are also quite capable.

Usage

You can generate subtitles for any video using the following command:

npx gen-subs for ./your/video.mp4

If you run this for the first time, you will be required to download a machine learning model to generate your subtitles. This needs to be done at least one time. Then, the program will generate a .srt file in your current working directory containing the subtitles for your video.

Inaccuracies

Please note that you may get inaccurate results with the default, basic English model. This model is 40MB and is meant to be a quick way to get started. It's not very smart, so your mileage may vary. If you'd like more accurate results, you can download a larger model by running the following command:

npx gen-subs models

This will have you choose a language and then show you a collection of models, their sizes, and intended use cases (like podcasting, content, etc.). You can then choose a model and download it. Once downloaded, you can use it to generate subtitles for your video. You only download models once, and can remove them any time by running npx gen-subs models purge. You can also list all your downloaded models by running npx gen-subs models ls.

Other Languages

You can install a wide variety of models that can "hear" different languages. To generate subs for any language, follow these steps:

  1. First, install a model with npx gen-subs models. You will be asked to choose a language here.
  2. Then, run npx gen-subs for ./your/video.mp4 to generate subtitles for your video, You will be asked which model to use.
  3. Enjoy!

API

This project has a few options that you can use to customize your subtitles. Let's enumerate them here. Each command comes after npx gen-subs and is followed by a list of options.

Command Description
for <mediaFile> Generate subtitles for a given video or audio file.
models Manage models
models purge Delete all downloaded models.
models ls Show a list of all models downloaded to the system.
burn-in <videoFile> <subtitleFile> Burns subtitles into the video and gives you a new video.
embed <videoFile> <subtitleFile> Adds subtitles to the video's metadata but does not alter the video.

gen-subs for [media]

Option Description Default
-m, --model [modelName] The name of the machine learning model you'd like to use to generate subtitles. vosk-model-small-en-us-0.15
-b, --burn-in Whether to layer subtitles atop the video (burn them in). None
-e, --embed Whether to embed subtitles in the video's metadata. None
-o, --out-dir [path] Where to output the subtitle and final video files. process.cwd()
-f, --format [format] Choose between srt or ass formats. ass lets you do more cool stuff like focus words. (Default srt) srt
-h --highlight [color] (ass subtitles only) Highlight the active word with a color. ⚠️ Use double quotes ("") when entering hex codes into your terminal because # starts a comment! "#048BA8"

Contributing

Please feel free to open issues and pull requests as needed and I'll try to get to them as soon as possible.

Sustainability

This is all free and open source software. If it has helped you, please consider sponsoring me on GitHub so I can make more stuff like this and teach about it full-time.

More Repositories

1

add-gitignore

An interactive CLI tool that adds a .gitignore to your projects.
JavaScript
636
star
2

basically-fullstack-graphql

Code that aims to explain the client and the server side of using GraphQL in apps.
JavaScript
201
star
3

basically-streams

An introductory project to the relatively new streaming APIs available in modern browsers.
JavaScript
131
star
4

danGPT

An AI of Dan Abramov using RAG and GenAI.
TypeScript
80
star
5

tejaskumar.com

my website nbd
TypeScript
38
star
6

babel-plugin-glamorous-to-emotion

A codemod to migrate existing React or Preact codebases from glamorous to emotion.
JavaScript
34
star
7

react-hook-intersection-observer

A simple React hook that works with the Intersection Observer API.
JavaScript
33
star
8

bookoid

An open source library management solution.
TypeScript
29
star
9

basically-react-suspense

An attempt to explain React Suspense to myself.
JavaScript
28
star
10

get-all-css-properties

An npm script that gets all the CSS properties, listed alphabetically.
TypeScript
27
star
11

basically-continuous-deployment

A simple project that aims to explain the process of continuous deployment.
JavaScript
25
star
12

praise

Do stuff with your voice in the browser.
TypeScript
13
star
13

react-server-components-from-scratch

This is from a YouTube video: https://youtu.be/F83wMYl9GWM
TypeScript
12
star
14

basically-web-workers

An introduction to Web Workers in basic terms.
JavaScript
11
star
15

event-sourcing-for-the-rest-of-us

Basically Kafka and Next.js
TypeScript
8
star
16

klar

A tool to infer and generate static type definitions based on resources returned by backend APIs.
JavaScript
8
star
17

favorite-javascript-flavors

My favorite styles in which to write JavaScript.
7
star
18

idli

Your AI command-line copilot
TypeScript
6
star
19

makeshift-next.js

A barebones Next.js from my YouTube video: https://www.youtube.com/watch?v=3RzhNYhjVAw
TypeScript
5
star
20

terraform-nodejs-screenshooter

A thing I made for a talk to teach people about Terraform and Infrastructure as Code.
HCL
5
star
21

tejjer-next13

TypeScript
5
star
22

restful-react-demo

Thing that talks to Giphy from ReactConf.
HTML
5
star
23

serverless-workshop

TypeScript
5
star
24

react-praise

A React binding for Praise.
TypeScript
4
star
25

tejjer-qwik

JavaScript
4
star
26

anna-artemov.now.sh

A basic website for my girlfriend's mom.
JavaScript
4
star
27

on-awesome

A little package to respond to people typing the word 'awesome' in web apps.
TypeScript
4
star
28

typescript-workshop-2019

Some exercises from my TypeScript workshop
TypeScript
4
star
29

jsconf-eu-2018-slides

My slides for JSconf EU 2018.
JavaScript
2
star
30

tejjer-solid

JavaScript
2
star
31

cli

A CLI of my name because yolo
JavaScript
2
star
32

typescript-trivia

Created with CodeSandbox
TypeScript
2
star
33

infusion-journal

A journal of my medical infusions
TypeScript
2
star
34

xss

A tutorial repo highlighting the basics of cross-site scripting.
TypeScript
2
star
35

react-suspense-pokedex

A bunch of things about streaming React for faster UIs.
JavaScript
2
star
36

react-fetch-with-roll-your-own-suspender

A demo of ad-hoc data fetching with React suspense that I made during a talk.
TypeScript
2
star
37

serverless-wedding

A simple demo of a serverless app with full CRUD functionality.
JavaScript
2
star
38

keel-todo

2
star
39

serverless-ssr-experiment

An experiment to learn how various UI frameworks behave when server rendered, serverless style.
JavaScript
1
star
40

saddleback-berlin-welcome

An app to serve newcomers to Saddleback Church in Berlin.
JavaScript
1
star
41

keel-thing

TypeScript
1
star
42

wasm-pack--303

A repo for an issue I opened.
Rust
1
star
43

better-gmail

I'm trying to make a better mail client
1
star
44

devjokes

TypeScript
1
star
45

limelightcollective.de

The website for the Limelight Collective
TypeScript
1
star
46

broken-counter

TypeScript
1
star
47

drawing-app

TypeScript
1
star
48

reddit-bug-fix-2

JavaScript
1
star
49

stuff-ive-learned-that-might-be-helpful-for-you--

Slides from my talk about best practices for development teams.
HTML
1
star
50

tejjer-next

TypeScript
1
star
51

tejjer-mitosis

TypeScript
1
star
52

qwikvercelbugrepro

TypeScript
1
star
53

g2i-gql-ts-thing

JavaScript
1
star
54

csp

A basic introduction to content security policies.
TypeScript
1
star
55

cli-preview

TypeScript
1
star