Package Exports
- @lordofmax/subtitle-generator
- @lordofmax/subtitle-generator/dist/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lordofmax/subtitle-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Subtitles Generator
Simple module written in Javascript with ECMAScript module format.
Exports one function that uses FFmpeg and AI to generate a subtitle file for a video.
FFmpeg must be installed.
Three models are available
- Gemini 2.5 Flash-Lite, requires a Gemini API key
- OpenAI Whisper, requires an OpenAI API key
- OpenAI Whisper installed locally, requires Python 3.9.9 and the package openai-whisper installed
$ py -3.9 -m pip install openai-whisper
Input:
- The path of the video file
- Model: openai, gemini or whisper (default)
- If OpenAI model: A valid OpenAI API key
Output:
- A subtitle file in the desired language, created in the same folder as the video folder.
Installation
$ npm install @lordofmax/subtitle-generatorExample
import { generateSubtitles } from "@lordofmax/subtitle-generator";
const videoFilePath = "./movie.mp4";
const openaiApiKey = "YOUR_OPENAI_API_KEY";
await generateSubtitles(videoFilePath);
await generateSubtitles(videoFilePath, { translateTo: "en" });
await generateSubtitles(videoFilePath, { openaiApiKey: openaiApiKey, model: "openai" });Command Line Interface
This package can also be used as a command line
$ npm install -g @lordofmax/subtitle-generator
$ sub -file path/to/video/file
$ sub -file path/to/video/file --translate en
$ sub -file path/to/video/file --key YOUR_OPENAI_API_KEY --model openai