How to Add an AI Voice Over to a Video using Node.js?

This Node.js example shows how to generate AI voiceovers using JavaScript. It uses ElevenLabs' text-to-speech API, along with Creatomate. Just specify a template, provide the voiceover text, and generate the video using a single API request:

Input Code
const Creatomate = require('creatomate');
const client = new Creatomate.Client('Your API Key');

client.render({

  // Design your own template, and provide its ID here.
  templateId: '58c1163e-f250-49df-b98d-e8c4aad01a2d',

  // Specify the text to be read aloud.
  modifications: {
    'Voiceover-1': 'The 3 Best Tips for Healthy Eating',
    'Voiceover-2': 'Prioritize Whole Foods: Opt for fruits, vegetables, whole grains, lean proteins and healthy fats. They\'re packed with nutrients and fiber for overall health.',
    'Voiceover-3': 'Stay Hydrated: Drink plenty of water to support digestion, regulate temperature, and maintain health. Limit sugary drinks and make water your go-to beverage.',
    'Voiceover-4': 'Plan Meals: Prep your meals and snacks ahead of time to avoid impulsive, unhealthy food choices. Keep nutritious foods on hand to stay on track with your health goals.'
  },

}).then((renders) => {
  console.log(renders);
});
Output Video

How it works: The quickest way to get started is using this step-by-step tutorial. Node.js users can use Creatomate's NPM package to invoke the API directly from their JavaScript applications. With this package, creating a voice-over video is as simple as calling the function "render".

The function receives two parameters; the template ID and the voiceover sentences. Templates can be designed with the online video editor or provided in JSON. This approach allows for a lot of flexibility; whether you are looking to generate engaging social media videos, or professional voiceovers for online courses.

It's up to you how much you'd like to automate the video production process – ranging from simple voiceovers to fully AI-generated videos. Creatomate's API lets you hook up all the major AI tools together, like ChatGPT to write the script, and DALL·E to use AI-generated images. Plus you can pick from dozens of subtitle styles, with animated captions that are perfectly in sync with the spoken text.

Generating voiceover videos is just one of Creatomate's many features. With its developer-driven approach, you can automate any video editing task to create dynamic videos, right from your JavaScript apps.

Sign up for a free account and give it a try.

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 Node.js application to create any kind of video – completely through code.

Related Node.js Video Editing Questions

Start automating today

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