Transcription
Functions
transcribeFile(client, id, options?)Start audio transcription for a video file
Returns:
TranscribeFileResultgetFileTranscription(client, id)Get transcription status for a file
Returns:
FileTranscriptionResult | nullGenerate audio transcriptions from uploaded video files.
transcribeFile
Start audio transcription for a video file.
import { transcribeFile } from "@editframe/api";const transcription = await transcribeFile(client, file.id, {trackId: 1, // Optional: specify audio track ID});console.log(transcription.id); // Transcription job IDconsole.log(transcription.file_id); // File IDconsole.log(transcription.track_id); // Audio track ID
If you don't specify trackId, Editframe uses the first audio track in the file.
getFileTranscription
Get transcription status for a file.
import { getFileTranscription } from "@editframe/api";const transcription = await getFileTranscription(client, file.id);if (transcription) {console.log(transcription.id);console.log(transcription.status); // "completed"console.log(transcription.work_slice_ms);console.log(transcription.completed_at);}
Returns null if the file has no transcription.
Complete Workflow
import {Client,createFile,uploadFile,getFileProcessingProgress,transcribeFile,getFileTranscription,} from "@editframe/api";import { createReadStream } from "node:fs";import { stat } from "node:fs/promises";const client = new Client(process.env.EDITFRAME_API_KEY);// 1. Upload video fileconst filePath = "video.mp4";const fileStats = await stat(filePath);const file = await createFile(client, {filename: "video.mp4",type: "video",byte_size: fileStats.size,});const fileStream = createReadStream(filePath);for await (const event of uploadFile(client,{ id: file.id, byte_size: fileStats.size, type: "video" },fileStream)) {if (event.type === "progress") {console.log(`Upload: ${event.progress.toFixed(1)}%`);}}// 2. Wait for processingfor await (const event of await getFileProcessingProgress(client, file.id)) {if (event.type === "progress") {console.log(`Processing: ${event.progress.toFixed(1)}%`);} else if (event.type === "complete") {break;}}// 3. Start transcriptionconst transcription = await transcribeFile(client, file.id);console.log("Transcription started:", transcription.id);// 4. Check transcription statusconst result = await getFileTranscription(client, file.id);if (result) {console.log("Status:", result.status);}
Using Transcriptions in Compositions
Once transcribed, use <ef-captions> with target to display captions:
<ef-configuration api-host="https://editframe.com"><ef-timegroup mode="contain" class="w-[1920px] h-[1080px]"><ef-video file-id="${file.id}"></ef-video><ef-captionstarget="ef-video"class="absolute bottom-10 left-10 right-10 text-white text-4xl text-center"></ef-captions></ef-timegroup></ef-configuration>
The <ef-captions> element with target="ef-video" automatically fetches transcription data from the video file. See the elements-composition skill for complete <ef-captions> documentation.