nodejs-whisper
Node.js bindings for OpenAI's Whisper model.
Features
- Automatically convert the audio to WAV format with a 16000 Hz frequency to support the whisper model.
- Output transcripts to (.txt .srt .vtt .json .wts .lrc)
- Optimized for CPU (Including Apple Silicon ARM)
- Timestamp precision to single word
- Split on word rather than on token (Optional)
- Translate from source language to english (Optional)
- Convert audio format to wav to support whisper model
Installation
- Install make tools
sudo apt update
sudo apt install build-essential
- Install nodejs-whisper with npm
npm i nodejs-whisper
- Download whisper model
npx nodejs-whisper download
- NOTE: user may need to install make tool
Windows Installation
-
Install MinGW-w64 or MSYS2 (which includes make tools)
-
Install nodejs-whisper with npm
npm i nodejs-whisper
- Download whisper model
npx nodejs-whisper download
- Note: Make sure mingw32-make or make is available in your system PATH.
Usage/Examples
See example/index.ts
(can be run with $ npm run test
)
import path from 'path'
import { nodewhisper } from 'nodejs-whisper'
const filePath = path.resolve(__dirname, 'YourAudioFileName')
await nodewhisper(filePath, {
modelName: 'base.en',
autoDownloadModelName: 'base.en',
removeWavFileAfterTranscription: false,
withCuda: false
logger: console
whisperOptions: {
outputInCsv: false,
outputInJson: false,
outputInJsonFull: false,
outputInLrc: false,
outputInSrt: true,
outputInText: false,
outputInVtt: false,
outputInWords: false,
translateToEnglish: false,
wordTimestamps: false,
timestamps_length: 20,
splitOnWord: true,
},
})
const MODELS_LIST = [
'tiny',
'tiny.en',
'base',
'base.en',
'small',
'small.en',
'medium',
'medium.en',
'large-v1',
'large',
'large-v3-turbo',
]
Types
interface IOptions {
modelName: string
removeWavFileAfterTranscription?: boolean
withCuda?: boolean
autoDownloadModelName?: string
whisperOptions?: WhisperOptions
logger?: Console
}
interface WhisperOptions {
outputInCsv?: boolean
outputInJson?: boolean
outputInJsonFull?: boolean
outputInLrc?: boolean
outputInSrt?: boolean
outputInText?: boolean
outputInVtt?: boolean
outputInWords?: boolean
translateToEnglish?: boolean
timestamps_length?: number
wordTimestamps?: boolean
splitOnWord?: boolean
}
Run locally
Clone the project
git clone https://github.com/ChetanXpro/nodejs-whisper
Go to the project directory
cd nodejs-whisper
Install dependencies
npm install
Start the server
npm run dev
Build project
npm run build
Made with
Feedback
If you have any feedback, please reach out to us at chetanbaliyan10@gmail.com
Authors