toCaptions()v4.0.216
将 transcribe() 的输出转换为 Caption 对象的数组,这样你就可以使用 @remotion/captions 的函数。
🌐 Converts the output from transcribe() into an array of Caption objects, so you can use the functions from @remotion/captions.
generate-captions.mjsimport {toCaptions ,transcribe } from '@remotion/install-whisper-cpp'; importpath from 'path'; constwhisperCppOutput = awaittranscribe ({inputPath : '/path/to/audio.wav',whisperPath :path .join (process .cwd (), 'whisper.cpp'),whisperCppVersion : '1.5.5',model : 'medium.en',tokenLevelTimestamps : true, }); const {captions } =toCaptions ({whisperCppOutput , });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, } ] */
另请参阅
🌐 See also