toCaptions()
Converts the output from transcribe()
into an array of Caption
objects, so you can use the functions from @remotion/captions
.
tsx
import {toCaptions ,transcribe ,resampleTo16Khz } from '@remotion/whisper-web';constfile = newFile ([], 'audio.wav');constchannelWaveform = awaitresampleTo16Khz ({file ,});constwhisperWebOutput = awaittranscribe ({channelWaveform ,model : 'tiny.en',});const {captions } =toCaptions ({whisperWebOutput ,});console .log (captions ); /*[{text: "William",startMs: 40,endMs: 420,timestampMs: 240,confidence: 0.813602,}, {text: " just",startMs: 420,endMs: 650,timestampMs: 480,confidence: 0.990905,}, {text: " hit",startMs: 650,endMs: 810,timestampMs: 700,confidence: 0.981798,}]*/