Generate-Subtitles
To Install
npm i generate-subtitles
Checkout source code at generate-subtitles repo
Description
This package parses video and audio files, to generate .vtt formatted subtitle files. The package is fully asynchronous and adds support for threads flag to run on lower powered systems complemented by file system support.
The package is built upon
Usage
Note- To run the script for first time the package needs to download the model which is then saved in /node_modules/generate-subtitles/lib/whisper.cpp/models
To do that, run
npx generate-subtitles download
and select an appropriate model.
Usage as modules
- Import generate function from the package.
import { generate } from "generate-subtitles";
- Now make the options data.
const options = {
inputFile: '/path/to/the/file',
outputDir: '/path/to/the/dir',
inputType: '/type_of_input(audio/video)',
whisperFlags: {
subFormat: 'vtt',
model: 'model_name',
language: 'language_name',
threadCount: number,
}
}
- Pass it to the function, which then outputs the .vtt file to output directory, with same name as input file.
try {
const getSubtiles= await generate(options);
} catch(error) {
}
Miscellaneous
-
When using audio input file, it requires .wav format at 16KHz frequency
-
In windows based system, make(Make for Windows).
Changelogs
@1.0.6
-
Fix: Language had an error, where it took input as model name.
@1.0.5
-
Fix: removed redundant check input.
-
Fix: OutputDir takes a filename, and outputs to that file.
-
Fix: removed unecessary lower case checks.
Acknowledgements
-
[Openai-whisper](Introducing Whisper)
-
Whisper.cpp
-
whisper-node