whisper-node
Node.js bindings for OpenAI's Whisper. Transcription done local.
Features
- Output transcripts to JSON (also .txt .srt .vtt)
- Optimized for CPU (Including Apple Silicon ARM)
- Timestamp precision to single word
Installation
- Add dependency to project
npm install whisper-node
- Download whisper model of choice
npx whisper-node download
Requirement for Windows: Install the make
command from here.
Usage
import whisper from 'whisper-node';
const transcript = await whisper("example/sample.wav");
console.log(transcript);
Output (JSON)
[
{
"start": "00:00:14.310",
"end": "00:00:16.480",
"speech": "howdy"
}
]
Usage with Additional Options
import whisper from 'whisper-node';
const filePath = "example/sample.wav";
const options = {
modelName: "base.en",
whisperOptions: {
language: 'auto'
gen_file_txt: false,
gen_file_subtitle: false,
gen_file_vtt: false,
word_timestamps: true
}
}
const transcript = await whisper(filePath, options);
Files must be .wav and 16Hz
Use FFmpeg to convert an example .mp3 with this command: ffmpeg -i input.mp3 -ar 16000 output.wav
Made with
Roadmap
Modifying whisper-node
npm run dev
- runs nodemon and tsc on '/src/test.ts'
npm run build
- runs tsc, outputs to '/dist' and gives sh permission to 'dist/download.js'
Acknowledgements