packages/docs/docs/install-whisper-cpp/index.mdx
With Whisper.cpp, you can transcribe audio locally on your machine.
This package provides easy to use cross-platform functions to install Whisper.cpp and a model.
import {TableOfContents} from './install-whisper-cpp';
<Installation pkg="@remotion/install-whisper-cpp" />Install Whisper 1.5.5 (the latest version at the time of writing that we find works well and supports token-level timestamps) and the medium.en model to the whisper.cpp folder.
import path from 'path';
import {downloadWhisperModel, installWhisperCpp, transcribe, toCaptions} from '@remotion/install-whisper-cpp';
import fs from 'fs';
const to = path.join(process.cwd(), 'whisper.cpp');
await installWhisperCpp({
to,
version: '1.5.5',
});
await downloadWhisperModel({
model: 'medium.en',
folder: to,
});
// Convert the audio to a 16KHz wav file first if needed:
// import {execSync} from 'child_process';
// execSync('ffmpeg -i /path/to/audio.mp4 -ar 16000 /path/to/audio.wav -y');
const whisperCppOutput = await transcribe({
model: 'medium.en',
whisperPath: to,
whisperCppVersion: '1.5.5',
inputPath: '/path/to/audio.wav',
tokenLevelTimestamps: true,
});
// Optional: Apply our recommended postprocessing
const {captions} = toCaptions({
whisperCppOutput,
});
fs.writeFileSync('captions.json', JSON.stringify(captions, null, 2));
MIT