How to Auto-Generate Subtitles using an API?

Auto-transcription involves automatically generating subtitles from audio or video clips, such as AI-generated voiceovers, using speech-to-text AI. The Creatomate video API supports generating animated, word-by-word captions using the following API request:

API Request
curl -s -X POST https://api.creatomate.com/v1/renders \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  --data-binary @- << EOF
{
  "output_format": "mp4",
  "source": {
    "elements": [
      {
        "type": "video",
        "id": "17ca2169-786f-477f-aaea-4a2598bf24eb",
        "source": "https://cdn.creatomate.com/demo/the-daily-stoic-podcast.mp4"
      },
      {
        "type": "text",
        "transcript_source": "17ca2169-786f-477f-aaea-4a2598bf24eb",
        "transcript_effect": "highlight",
        "transcript_maximum_length": 14,
        "y": "82%",
        "width": "81%",
        "height": "35%",
        "x_alignment": "50%",
        "y_alignment": "50%",
        "fill_color": "#ffffff",
        "stroke_color": "#000000",
        "stroke_width": "1.6 vmin",
        "font_family": "Montserrat",
        "font_weight": "700",
        "font_size": "9.29 vmin",
        "background_color": "rgba(216,216,216,0)",
        "background_x_padding": "31%",
        "background_y_padding": "17%",
        "background_border_radius": "31%"
      }
    ]
  }
}
EOF
Output Video

How it works: This example uses cURL to invoke the Creatomate video editing API, however you can also do this in your own software application or automated workflow since it is just a single HTTP request.

For this example, we're passing two elements to the API; a video and a text element. The video element contains the video clip that we want to transcribe. Using the "source" parameter, we can specify any video URL.

Automated captions are set up using the "text" element. Here, we're referring to the video element by the "transcript_source" attribute, so the API knows which video to generate subtitles for. The remaining attributes are used to style, position, and animate the captions. Here are some examples using different attributes:

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.

Creatomate is a video automation API that goes beyond generating subtitles. You can do almost any automated video task, such as trimming, stitching, overlaying elements, and many more. Check out the examples further down this page to see what else is possible.

To get started, follow this quick tutorial or check out the API documentation.

Edit this Code Example in the Video Editor

Easily design your own video templates using the online editor. Then, export your templates as JSON and integrate them into your application to create any kind of video – completely through code.

Related API Video Editing Questions

Start automating today

Start with a full-featured trial with 50 credits, no credit card required.
Get started for free