Skip to content

🎥 Make videos programmatically with React

`@remotion/openai-whisper`: Reject tasks that are `task: "translate"`

Jonny Burgerad4e35528ca4
diff --git a/packages/openai-whisper/src/openai-format.ts b/packages/openai-whisper/src/openai-format.ts
index 288416a658..a7a141ece0 100644
--- a/packages/openai-whisper/src/openai-format.ts
+++ b/packages/openai-whisper/src/openai-format.ts
@@ -19,7 +19,7 @@ export interface TranscriptionSegment {
export interface OpenAiVerboseTranscription {
duration: number | string;
- task?: string;
+ task?: 'transcribe';
language: string;
text: string;
segments?: Array<TranscriptionSegment>;
diff --git a/packages/openai-whisper/src/openai-whisper-api-to-captions.ts b/packages/openai-whisper/src/openai-whisper-api-to-captions.ts
index 3eff7d1d9e..5198ce4b5c 100644
--- a/packages/openai-whisper/src/openai-whisper-api-to-captions.ts
+++ b/packages/openai-whisper/src/openai-whisper-api-to-captions.ts
@@ -13,7 +13,14 @@ export const openAiWhisperApiToCaptions = ({
transcription,
}: OpenAiToCaptionsInput): OpenAiToCaptionsOutput => {
const captions: Caption[] = [];
+
if (!transcription.words) {
+ if (transcription.task && transcription.task !== 'transcribe') {
+ throw new Error(
+ `The transcription does need to be a "transcribe" task. The input you gave is "task": "${transcription.task}"`,
+ );
+ }
+
throw new Error(
'The transcription does need to be been generated with `timestamp_granularities: ["word"]`',
);