Skip to content

🎥 Make videos programmatically with React

update

Jonny Burgerae7def462db9
diff --git a/packages/docs/docs/whisper-wasm/transcribe.mdx b/packages/docs/docs/whisper-wasm/transcribe.mdx
index 9e8a9ad8ec..81a85f56be 100644
--- a/packages/docs/docs/whisper-wasm/transcribe.mdx
+++ b/packages/docs/docs/whisper-wasm/transcribe.mdx
@@ -3,13 +3,38 @@ title: transcribe()
crumb: '@remotion/whisper-wasm'
---
+# transcribe()
+
:::warning
**Unstable API**: This package is experimental for the moment. As we test it, we might make a few changes to the API.
:::
-# transcribe()
+Transcribes pre-processed audio data (a `Float32Array` waveform) using WebAssembly-compiled Whisper.cpp, returning the transcription.
+
+To transcribe an audio file, you first need to download a model using [`downloadWhisperModel()`](/docs/whisper-wasm/download-whisper-model) and turn the file into a 16kHz `Float32Array` using [`resampleTo16Khz()`](/docs/whisper-wasm/resample-to-16khz).
-Transcribes pre-processed audio data (a `Float32Array` waveform) using WebAssembly-compiled `whisper.cpp`, returning the transcription. To transcribe an audio file, you first need to process it using [`resampleTo16Khz()`](/docs/whisper-wasm/resample-to-16khz).
+## Example
+
+```tsx twoslash title="app.ts"
+import {resampleTo16Khz} from '@remotion/whisper-wasm';
+const file = new File([], 'audio.wav');
+
+const channelWaveform = await resampleTo16Khz({
+ file,
+ onProgress: (p) => console.log(`Resampling audio (${Math.round(p * 100)}%)...`),
+});
+
+// ---cut---
+import {transcribe} from '@remotion/whisper-wasm';
+
+const {transcription} = await transcribe({
+ channelWaveform,
+ model: 'tiny.en',
+ onProgress: (p) => console.log(`Transcribing (${Math.round(p * 100)}%)...`),
+});
+
+console.log(transcription.map((t) => t.text).join(' '));
+```
## Arguments
@@ -73,5 +98,5 @@ Determines how much info is being logged to the console.
- [Source code for `transcribe()`](https://github.com/remotion-dev/remotion/blob/main/packages/whisper-wasm/src/transcribe.ts)
- [`resampleTo16Khz()`](/docs/whisper-wasm/resample-to-16khz)
-- [`@remotion/whisper-wasm`](/docs/whisper-wasm)
- [`downloadWhisperModel()`](/docs/whisper-wasm/download-whisper-model)
+- [`@remotion/whisper-wasm`](/docs/whisper-wasm)
diff --git a/packages/example/src/WhisperWasm/index.tsx b/packages/example/src/WhisperWasm/index.tsx
index 18f3e27da3..12a449f5b5 100644
--- a/packages/example/src/WhisperWasm/index.tsx
+++ b/packages/example/src/WhisperWasm/index.tsx
@@ -38,8 +38,8 @@ export const WhisperWasm = () => {
try {
const {alreadyDownloaded} = await downloadWhisperModel({
model: selectedModel,
- onProgress: (progress) => {
- console.log(progress);
+ onProgress: ({progress, totalBytes, downloadedBytes}) => {
+ console.log({progress, totalBytes, downloadedBytes});
setStatusMessage(
`Downloading ${selectedModel} model... ${(progress * 100).toFixed(
0,