🎥 Make videos programmatically with React
scope storeFS
Jonny Burger4e5601e24657
diff --git a/packages/example/src/WhisperWasm/index.tsx b/packages/example/src/WhisperWasm/index.tsxindex 964636f323..9cd34633c1 100644--- a/packages/example/src/WhisperWasm/index.tsx+++ b/packages/example/src/WhisperWasm/index.tsx@@ -11,16 +11,22 @@ import {staticFile} from 'remotion';export const WhisperWasm = () => {const [loadedModels, setLoadedModels] = useState<WhisperModel[]>([]);+ const fetchModels = useCallback(async () => {+ const models = await getLoadedModels();+ setLoadedModels(models);+ }, []);+const onClick = useCallback(async () => {const {alreadyDownloaded} = await downloadWhisperModel({- model: 'tiny',+ model: 'tiny.en',onProgress: (progress) => {console.log(progress);},});+ fetchModels();console.log({alreadyDownloaded});- }, []);+ }, [fetchModels]);const onClickTranscribe = useCallback(async () => {const file = await fetch(staticFile('16khz.wav'));@@ -34,11 +40,6 @@ export const WhisperWasm = () => {});}, []);- const fetchModels = useCallback(async () => {- const models = await getLoadedModels();- setLoadedModels(models);- }, []);-useEffect(() => {fetchModels();}, [fetchModels]);diff --git a/packages/whisper-wasm/src/constants.ts b/packages/whisper-wasm/src/constants.tsindex 2ead0c90bd..8da8fe402a 100644--- a/packages/whisper-wasm/src/constants.ts+++ b/packages/whisper-wasm/src/constants.ts@@ -1,5 +1,4 @@export const DB_NAME = 'whisper-wasm';-export const FILE_DESTINATION = 'whisper.bin';export const DB_VERSION = 1;export const DB_OBJECT_STORE_NAME = 'models';diff --git a/packages/whisper-wasm/src/transcribe.ts b/packages/whisper-wasm/src/transcribe.tsindex baaaf16a95..1b5fadd5cc 100644--- a/packages/whisper-wasm/src/transcribe.ts+++ b/packages/whisper-wasm/src/transcribe.ts@@ -3,7 +3,7 @@import type {MainModule} from '../main';import {checkForHeaders} from './check-for-headers';-import {FILE_DESTINATION, type WhisperModel} from './constants';+import {type WhisperModel} from './constants';import {getObject} from './db/get-object-from-db';import {getModelUrl} from './get-model-url';import {loadMod} from './load-mod/load-mod';@@ -135,7 +135,9 @@ export const transcribe = async ({);}- storeFS(Mod, FILE_DESTINATION, result);+ const fileName = `${model}.bin`;++ storeFS(Mod, fileName, result);return new Promise((resolve) => {checkForHeaders();@@ -147,7 +149,7 @@ export const transcribe = async ({}if (!instance) {- instance = Mod.init(FILE_DESTINATION);+ instance = Mod.init(fileName);if (!instance) {transcribing = false;throw new Error('Failed to initialize Whisper.');