How to Add an AI Voice Over to a Video using Python?

This example demonstrates how to generate AI voiceovers with your Python script. It uses ElevenLabs' text-to-speech API, along with Creatomate. Simply specify a template, input the voiceover text, and create the video with a single API request.

Input Code
import requests

json = {
 # Design your own template, and provide its ID here.
 'template_id': '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.'
 }
}

response = requests.post(
 'https://api.creatomate.com/v1/renders',
 headers={
  # Find your API key under 'Project Settings' in your account:
  # https://creatomate.com/docs/api/rest-api/authentication
  'Authorization': 'Bearer Your-API-Key',
  'Content-Type': 'application/json',
 },
 json=json
)

# Wait a minute, then visit the URL provided in the response:
print(response.json())

Output Video

How it works: The quickest way to get started is using this step-by-step tutorial. There is no need to install any additional software – Python users can simply use the standard "requests" library to make HTTP requests.

Creating a voiceover video takes just one POST request, where you pass in your template ID and voiceover text. The online template editor lets you fully customize the voiceover video, whether you're producing social media videos, instructional videos (like online courses), or personalized videos.

You can choose the level of automation in your video production, ranging from basic voiceovers to fully AI-generated videos. Creatomate's API seamlessly integrates with leading AI tools, like ChatGPT for scriptwriting and DALL·E for generating AI images. You can also choose from dozens of subtitle styles, including animated captions that sync with the spoken words.

Voiceover videos are just one of the many options Creatomate has to offer. Using its developer-focused approach, you can automate any video editing task directly from your Python code.

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

Related Python Video Editing Questions

Start automating today

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