1.0.9 • Published 12 months ago
@lordofmax/subtitle-generator v1.0.9
Subtitles Generator
Simple module written in Javascript with ECMAScript module format.
Exports one function that uses FFmpeg and OpenAI Whisper API to generate an English subtitle file for a video in a foreign language.
FFmpeg must be installed.
Input:
- The path of the video file
- A valid OpenAI API key
- A comma-separated list of words helpful for correcting specific words or acronyms that the model may misrecognize. The string will be used as-is in the OpenAI Whisper prompt. Should be in English.
Output:
- A subtitle file in the desired language, created in the same folder as the video folder.
Installation
$ npm install @lordofmax/subtitle-generator
Example
import {generateSubtitles} from "@lordofmax/subtitle-generator";
const videoFilePath = './movie.mp4';
const openaiApiKey = 'YOUR_OPENAI_API_KEY';
await generateSubtitles(videoFilePath, openaiApiKey, null);
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 -apikey your_openai_api_key