With auto-transcription, you can automatically generate subtitles for any video or audio file, including AI-generated voiceovers. This is an automated process in which captions are generated using speech-to-text AI, which identifies spoken words and turns them into animated subtitles. Here's how to do it in your Node.js app using a few lines of JavaScript:
const Creatomate = require('creatomate');
const client = new Creatomate.Client('Your API Key');
client.render({
source: new Creatomate.Source({
outputFormat: 'mp4',
elements: [
new Creatomate.Video({
id: '17ca2169-786f-477f-aaea-4a2598bf24eb',
source: 'https://cdn.creatomate.com/demo/the-daily-stoic-podcast.mp4',
}),
new Creatomate.Text({
transcriptSource: '17ca2169-786f-477f-aaea-4a2598bf24eb',
transcriptEffect: 'highlight',
transcriptMaximumLength: 14,
y: '82%',
width: '81%',
height: '35%',
xAlignment: '50%',
yAlignment: '50%',
fillColor: '#ffffff',
strokeColor: '#000000',
strokeWidth: '1.6 vmin',
fontFamily: 'Montserrat',
fontWeight: '700',
fontSize: '9.29 vmin',
backgroundColor: 'rgba(216,216,216,0)',
backgroundXPadding: '31%',
backgroundYPadding: '17%',
backgroundBorderRadius: '31%',
}),
],
}),
}).then((renders) => {
console.log(renders);
});
How it works: As a first step, install the Creatomate package from NPM, which allows you to edit video directly from your Node.js code. With this package, we get a straightforward way to use Creatomate's video API; the video is made with just one call to "render".
In the JSON object we pass to the "render" function, we tell the API how to make the subtitled video. In this case, we're using two elements: a video element and a text element.
The "source" parameter points to an MP4 clip for which subtitles should be generated. As a next step, we add a text element that will contain the auto-generated captions. With the "transcriptSource" parameter, we can specify the video element's ID so that the API uses that as the basis for creating captions.
The remaining attributes are used to style, position, and animate the captions. In terms of customization, you can pick from many different subtitle styles. The easiest way to explore the different caption attributes is using the video editor below.
We've also written a step-by-step tutorial on making videos with AI-generated voiceovers and matching subtitles. Even if you're looking to generate subtitles for other types of video or audio files, this guide is helpful for setting up a subtitle generation template.
Auto-transcription is just one of Creatomate's features. With its developer-driven approach, you can automate any video editing task to create dynamic videos, right from your JavaScript apps. To get started, follow this quick tutorial or check out the API documentation.