@remotion/whisper-web
warning
Unstable API: This package is experimental for the moment. As we test it, we might make a few changes to the API and switch to a WebGPU-based backend in the future.
Similar to @remotion/install-whisper-cpp but for the browser. Allows you to transcribe audio locally in the browser, with the help of WASM.
- npm
- yarn
- pnpm
- bun
npm i --save-exact @remotion/whisper-web@4.0.302
pnpm i @remotion/whisper-web@4.0.302
bun i @remotion/whisper-web@4.0.302
yarn --exact add @remotion/whisper-web@4.0.302
Also update
remotion
and all `@remotion/*`
packages to the same version.Remove all
^
character in front of the version numbers of it as it can lead to a version conflict.Example usage
info
This library is UI-agnostic and can be integrated with any frontend framework.
tsx
import {transcribe ,canUseWhisperWeb ,resampleTo16Khz ,downloadWhisperModel } from '@remotion/whisper-web';// HTML:// <input type="file" accept="audio/*" id="audio-input" />// <p id="status"></p>constinput =document .getElementById ('audio-input') asHTMLInputElement ;input .addEventListener ('change', async (e ) => {constfile =input .files ?.[0];if (!file ) return;console .log ('Processing...');constmodelToUse = 'tiny.en';const {supported ,detailedReason } = awaitcanUseWhisperWeb (modelToUse );if (!supported ) {throw newError (`Whisper Web is not supported in this environment: ${detailedReason }`);}console .log ('Downloading model...');awaitdownloadWhisperModel ({model :modelToUse ,onProgress : ({progress }) =>console .log (`Downloading model (${Math .round (progress * 100)}%)...`),});console .log ('Resampling audio...');constchannelWaveform = awaitresampleTo16Khz ({file ,onProgress : (p ) =>console .log (`Resampling audio (${Math .round (p * 100)}%)...`),});console .log ('Transcribing...');const {transcription } = awaittranscribe ({channelWaveform ,model :modelToUse ,onProgress : (p ) =>console .log (`Transcribing (${Math .round (p * 100)}%)...`),});console .log (transcription .map ((t ) =>t .text ).join (' '));});
Functions
canUseWhisperWeb()
Check if the browser supports this Whisper package
downloadWhisperModel()
Download a Whisper model in browser
resampleTo16khz()
Prepare an audio file for transcription by resampling it to 16kHz
transcribe()
Transcribe an audio file in the WASM environemnt
getLoadedModels()
Get a list of Whisper models that are already downloaded
License
MIT