Captions

API

Once a video file has been uploaded, and processed, a transcription can be generated for it.

You will need to determine the trackId of the track you want to transcribe. This should be an audio track. A typical video file might have one audio track, and one video track. But it could have many audio tracks, and you can choose which one you want to transcribe.

You may supply a trackId to the transcription function, but it is optional. If you do not supply one, the first audio track found will be used.

If no audio tracks are found, or the supplied trackId does not match any of the audio tracks found, the transcription request will fail with a 400 status code.

Create a client

Import required functions and set up your API client.

import { Client, transcribeISOBMFFFile } from "@editframe/api/node";
const EF_TOKEN = "/* Load your API TOKEN */";
const client = new Client(EF_TOKEN);

Initiate the transcription

If the selected track has already had a transcription initiated, this will return the existing record.

const fileId = "/* fileId returned from upload/processing operations */";
const transcriptionRecord = await transcribeISOBMFFFile(client, fileId);

Wait for the transcription to complete

The transcription will be queued, and you can receive progress updates.

const progress = getTranscriptionProgress(client, transcriptionRecord.id);

for await (const event of progress) {
  console.log(event.data.progress);
  // {
  //   type: "progress";
  //   progress: number; // Between 0 and 1
  // }
}

// Alternatively, you may await a promise that resolves when the transcription is complete:
await progress.whenComplete();

When using the <ef-captions>/<Captions> component, you will target the an <ef-video>/<Video> or <ef-audio>/<Audio> file. Those elements will automatically connect to the Editframe api to fetch the appropriate transcription data.