🎥 Make videos programmatically with React
Upgrade Whisper.cpp
Igor Samokhovetse93df109e172
diff --git a/packages/template-audiogram/transcribe.ts b/packages/template-audiogram/transcribe.tsindex 91ab10b238..dd82605acd 100644--- a/packages/template-audiogram/transcribe.ts+++ b/packages/template-audiogram/transcribe.ts@@ -1,21 +1,25 @@import path from "path";+import fs from 'fs'import {downloadWhisperModel,installWhisperCpp,transcribe,toCaptions,+ type WhisperModel,} from "@remotion/install-whisper-cpp";-const to = path.join(process.cwd(), "whisper.cpp");+const WHISPER_VERSION = process.platform === "win32" ? "1.6.0" : "1.7.4";+const WHISPER_MODEL: WhisperModel = "medium";+const WHISPER_PATH = path.join(process.cwd(), "whisper.cpp");await installWhisperCpp({- to,- version: "1.5.5",+ to: WHISPER_PATH,+ version: WHISPER_VERSION,});await downloadWhisperModel({- model: "medium",- folder: to,+ model: WHISPER_MODEL,+ folder: WHISPER_PATH,});// Convert the audio to a 16KHz wav file first if needed:@@ -23,11 +27,12 @@ await downloadWhisperModel({// execSync('ffmpeg -i /path/to/audio.mp4 -ar 16000 /path/to/audio.wav -y');const whisperCppOutput = await transcribe({- model: "medium",- whisperPath: to,- inputPath: path.join(process.cwd(), "./out.wav"),+ model: WHISPER_MODEL,+ whisperPath: WHISPER_PATH,+ inputPath: path.join(process.cwd(), "./public/podcast-audio-16.wav"),tokenLevelTimestamps: true,language: "German",+ whisperCppVersion: WHISPER_VERSION,});// Optional: Apply our recommended postprocessing@@ -36,3 +41,8 @@ const { captions } = toCaptions({});console.log(JSON.stringify(captions));++fs.writeFileSync(+ path.join(process.cwd(), "./public/captions.json"),+ JSON.stringify(captions, null, 2),+);