Skip to content

🎥 Make videos programmatically with React

fix stuff

Jonny Burgerd3e89cfdc74e
diff --git a/packages/docs/docs/whisper-web/can-use-whisper-web.mdx b/packages/docs/docs/whisper-web/can-use-whisper-web.mdx
index 8da173814f..ec02f434de 100644
--- a/packages/docs/docs/whisper-web/can-use-whisper-web.mdx
+++ b/packages/docs/docs/whisper-web/can-use-whisper-web.mdx
@@ -24,8 +24,8 @@ export default function MyComponent() {
useEffect(() => {
const checkSupport = async () => {
- const modelToUse: WhisperWasmModel = 'tiny.en'; // Or any other model
- const result = await canUseWhisperWasm(modelToUse);
+ const modelToUse: WhisperWebModel = 'tiny.en'; // Or any other model
+ const result = await canUseWhisperWeb(modelToUse);
setSupported(result.supported);
if (!result.supported) {
setReason(result.detailedReason ?? result.reason);
@@ -36,14 +36,14 @@ export default function MyComponent() {
}, []);
if (supported === null) {
- return <p>Checking Whisper WASM support...</p>;
+ return <p>Checking if Whisper Web can be used...</p>;
}
if (supported) {
- return <p>Whisper WASM is supported!</p>;
+ return <p>Can use Whisper Web!</p>;
}
- return <p>Whisper WASM is not supported: {reason}</p>;
+ return <p>Using Whisper Web is not possible: {reason}</p>;
}
```
@@ -54,15 +54,15 @@ export default function MyComponent() {
The Whisper model intended to be used. This is used to check if there's enough storage space for the model.
Possible values: `tiny`, `tiny.en`, `base`, `base.en`, `small`, `small.en`.
-Refer to the `WhisperWasmModel` type exported by the package for a comprehensive list.
+Refer to the `WhisperWebModel` type exported by the package for a comprehensive list.
## Return value
-A `Promise` that resolves to a `CanUseWhisperWasmResult` object with the following properties:
+A `Promise` that resolves to a `CanUseWhisperWebResult` object with the following properties:
### `supported`
-A boolean indicating whether Whisper WASM can be used. `true` if supported, `false` otherwise.
+A boolean indicating whether a transcription can be done. `true` if supported, `false` otherwise.
### `reason?`
@@ -81,7 +81,7 @@ Possible values values include:
### `detailedReason?`
-If `supported` is `false`, this field may contain a more detailed, human-readable explanation of why Whisper WASM is not supported.
+If `supported` is `false`, this field may contain a more detailed, human-readable explanation of why a transcription is not possible.
## Important considerations
@@ -95,7 +95,7 @@ If `supported` is `false`, this field may contain a more detailed, human-readabl
## See also
-- [Source code for `canUseWhisperWasm()`](https://github.com/remotion-dev/remotion/blob/main/packages/whisper-web/src/can-use-whisper-web.ts)
+- [Source code for `canUseWhisperWeb()`](https://github.com/remotion-dev/remotion/blob/main/packages/whisper-web/src/can-use-whisper-web.ts)
- [`@remotion/whisper-web`](/docs/whisper-web)
- [`transcribe()`](/docs/whisper-web/transcribe)
- [`downloadWhisperModel()`](/docs/whisper-web/download-whisper-model)
diff --git a/packages/docs/docs/whisper-web/index.mdx b/packages/docs/docs/whisper-web/index.mdx
index 12aee22d0d..130c024c92 100644
--- a/packages/docs/docs/whisper-web/index.mdx
+++ b/packages/docs/docs/whisper-web/index.mdx
@@ -42,13 +42,13 @@ input.addEventListener('change', async (e) => {
const {supported, detailedReason} = await canUseWhisperWeb(modelToUse);
if (!supported) {
- throw new Error(`Whisper WASM is not supported in this environment: ${detailedReason}`);
+ throw new Error(`Whisper Web is not supported in this environment: ${detailedReason}`);
}
console.log('Downloading model...');
await downloadWhisperModel({
model: modelToUse,
- onProgress: (p) => console.log(`Downloading model (${Math.round(p * 100)}%)...`),
+ onProgress: ({progress}) => console.log(`Downloading model (${Math.round(progress * 100)}%)...`),
});
console.log('Resampling audio...');
diff --git a/packages/docs/docs/whisper-web/whisper-wasm.tsx b/packages/docs/docs/whisper-web/whisper-web.tsx
similarity index 100%
rename from packages/docs/docs/whisper-web/whisper-wasm.tsx
rename to packages/docs/docs/whisper-web/whisper-web.tsx
diff --git a/packages/example/src/WhisperWeb/index.tsx b/packages/example/src/WhisperWeb/index.tsx
index cab9c85dc4..b3e4b9537b 100644
--- a/packages/example/src/WhisperWeb/index.tsx
+++ b/packages/example/src/WhisperWeb/index.tsx
@@ -1,5 +1,5 @@
import {
- type WhisperWasmModel as WhisperWebModel,
+ type WhisperWebModel,
deleteModel,
downloadWhisperModel,
getLoadedModels,
@@ -133,7 +133,7 @@ export const WhisperWeb = () => {
<div className="flex flex-col items-center justify-center min-h-screen bg-black p-4">
<div className="w-full max-w-md bg-white shadow-lg rounded-lg p-6 space-y-4">
<div className="text-center text-2xl font-semibold text-gray-700">
- Whisper WASM Demo
+ Whisper Web Demo
</div>
{statusMessage && (
diff --git a/packages/whisper-web/src/can-use-whisper-web.ts b/packages/whisper-web/src/can-use-whisper-web.ts
index 457a57ec47..0528518c49 100644
--- a/packages/whisper-web/src/can-use-whisper-web.ts
+++ b/packages/whisper-web/src/can-use-whisper-web.ts
@@ -1,7 +1,7 @@
import type {WhisperWebModel} from './constants';
import {SIZES} from './constants';
-export enum WhisperWasmUnsupportedReason {
+export enum WhisperWebUnsupportedReason {
WindowUndefined = 'window-undefined',
IndexedDbUnavailable = 'indexed-db-unavailable',
NavigatorStorageUnavailable = 'navigator-storage-unavailable',
@@ -13,19 +13,19 @@ export enum WhisperWasmUnsupportedReason {
NotCrossOriginIsolated = 'not-cross-origin-isolated',
}
-export interface CanUseWhisperWasmResult {
+export interface CanUseWhisperWebResult {
supported: boolean;
- reason?: WhisperWasmUnsupportedReason;
+ reason?: WhisperWebUnsupportedReason;
detailedReason?: string;
}
-export const canUseWhisperWasm = async (
+export const canUseWhisperWeb = async (
model: WhisperWebModel,
-): Promise<CanUseWhisperWasmResult> => {
+): Promise<CanUseWhisperWebResult> => {
if (typeof window === 'undefined') {
return {
supported: false,
- reason: WhisperWasmUnsupportedReason.WindowUndefined,
+ reason: WhisperWebUnsupportedReason.WindowUndefined,
detailedReason:
'`window` is not defined. This module can only be used in a browser environment.',
};
@@ -34,7 +34,7 @@ export const canUseWhisperWasm = async (
if (!window.crossOriginIsolated) {
return {
supported: false,
- reason: WhisperWasmUnsupportedReason.NotCrossOriginIsolated,
+ reason: WhisperWebUnsupportedReason.NotCrossOriginIsolated,
detailedReason:
'The document is not cross-origin isolated (window.crossOriginIsolated = false). This prevents the usage of SharedArrayBuffer, which is required by `@remotion/whisper-web`. Make sure the document is served with the HTTP header `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`: https://developer.mozilla.org/en-US/docs/Web/API/Window/crossOriginIsolated',
};
@@ -43,7 +43,7 @@ export const canUseWhisperWasm = async (
if (!window.indexedDB) {
return {
supported: false,
- reason: WhisperWasmUnsupportedReason.IndexedDbUnavailable,
+ reason: WhisperWebUnsupportedReason.IndexedDbUnavailable,
detailedReason: 'IndexedDB is not available in this environment.',
};
}
@@ -51,7 +51,7 @@ export const canUseWhisperWasm = async (
if (!navigator?.storage || !navigator?.storage.estimate) {
return {
supported: false,
- reason: WhisperWasmUnsupportedReason.NavigatorStorageUnavailable,
+ reason: WhisperWebUnsupportedReason.NavigatorStorageUnavailable,
detailedReason:
'`navigator.storage.estimate()` API is not available in this environment.',
};
@@ -63,7 +63,7 @@ export const canUseWhisperWasm = async (
if (estimate.quota === undefined) {
return {
supported: false,
- reason: WhisperWasmUnsupportedReason.QuotaUndefined,
+ reason: WhisperWebUnsupportedReason.QuotaUndefined,
detailedReason:
'navigator.storage.estimate() API returned undefined quota.',
};
@@ -72,7 +72,7 @@ export const canUseWhisperWasm = async (
if (estimate.usage === undefined) {
return {
supported: false,
- reason: WhisperWasmUnsupportedReason.UsageUndefined,
+ reason: WhisperWebUnsupportedReason.UsageUndefined,
detailedReason:
'navigator.storage.estimate() API returned undefined usage.',
};
@@ -84,7 +84,7 @@ export const canUseWhisperWasm = async (
if (remaining < modelSize) {
return {
supported: false,
- reason: WhisperWasmUnsupportedReason.NotEnoughSpace,
+ reason: WhisperWebUnsupportedReason.NotEnoughSpace,
detailedReason: `Not enough space to download the model. Required: ${modelSize} bytes, Available: ${remaining} bytes.`,
};
}
@@ -92,7 +92,7 @@ export const canUseWhisperWasm = async (
const errorMessage = error instanceof Error ? error.message : String(error);
return {
supported: false,
- reason: WhisperWasmUnsupportedReason.ErrorEstimatingStorage,
+ reason: WhisperWebUnsupportedReason.ErrorEstimatingStorage,
detailedReason: `Error estimating storage: ${errorMessage}`,
};
}
diff --git a/packages/whisper-web/src/download-whisper-model.ts b/packages/whisper-web/src/download-whisper-model.ts
index d2c171630c..3bb30a0112 100644
--- a/packages/whisper-web/src/download-whisper-model.ts
+++ b/packages/whisper-web/src/download-whisper-model.ts
@@ -1,4 +1,4 @@
-import {canUseWhisperWasm} from './can-use-whisper-web';
+import {canUseWhisperWeb} from './can-use-whisper-web';
import {MODELS, SIZES, type WhisperWebModel} from './constants';
import {getObject} from './db/get-object-from-db';
import {putObject} from './db/put-object';
@@ -34,7 +34,7 @@ export const downloadWhisperModel = async ({
);
}
- const usabilityCheck = await canUseWhisperWasm(model);
+ const usabilityCheck = await canUseWhisperWeb(model);
if (!usabilityCheck.supported) {
return Promise.reject(
diff --git a/packages/whisper-web/src/index.ts b/packages/whisper-web/src/index.ts
index b09a918074..8e22c5520a 100644
--- a/packages/whisper-web/src/index.ts
+++ b/packages/whisper-web/src/index.ts
@@ -1,7 +1,7 @@
import type {
- CanUseWhisperWasmResult,
- canUseWhisperWasm as originalCanUseWhisperWasm,
- WhisperWasmUnsupportedReason,
+ CanUseWhisperWebResult,
+ canUseWhisperWeb as originalCanUseWhisperWeb,
+ WhisperWebUnsupportedReason,
} from './can-use-whisper-web';
import type {WhisperWebLanguage, WhisperWebModel} from './constants';
import type {deleteModel as originalDeleteModel} from './delete-model';
@@ -46,7 +46,7 @@ export const deleteModel: typeof originalDeleteModel = () => {
);
};
-export const canUseWhisperWasm: typeof originalCanUseWhisperWasm = () => {
+export const canUseWhisperWeb: typeof originalCanUseWhisperWeb = () => {
throw new Error(
'Loading this module from CommonJS is not supported. Load the ESM version of @remotion/whisper-web.',
);
@@ -59,14 +59,14 @@ export const resampleTo16Khz: typeof originalResampleTo16Khz = () => {
};
export type {
- CanUseWhisperWasmResult,
+ CanUseWhisperWebResult,
DownloadWhisperModelOnProgress,
DownloadWhisperModelParams,
DownloadWhisperModelProgress,
DownloadWhisperModelResult,
ResampleTo16KhzParams,
TranscribeParams,
- WhisperWebLanguage as WhisperWasmLanguage,
- WhisperWebModel as WhisperWasmModel,
- WhisperWasmUnsupportedReason,
+ WhisperWebLanguage,
+ WhisperWebModel,
+ WhisperWebUnsupportedReason,
};