Automate your Reels and TikToks Generation using Python

Chouaieb Nemri
4 min readMay 8, 2023

In this blog, I guide you through automating your video content generation using python and generative AI. By the end of this blog, you’ll be capable of:

  • Create TikTok videos and Instagram reels featuring your virtual avatar
  • Automatically generating a video script by just providing a 1-line idea to your content pipeline using OpenAI API.
  • Automatically generating voice over for your video script using ElevenLabs API
  • Automatically generate videos where your virtual avatar says your video script using D-ID API

Register to ElevenLabs and Create your Voice

  • Go to ElevenLabs website and register (Starter plan is recommended if you want to clone your voice)
  • Follow the following steps to clone your voice

Register to D-ID and create your avatar

  • Go to D-ID website and register (Lite plan is preferred to have a personal avatar)
  • Follow the following steps to create your avatar

Register to OpenAI

  • Register to OpenAI and create a new API key.

Automate your content pipeline using Python

Script generation

For script generation piece, we’ll use LangChain, which is a framework for developing applications powered by language models.

from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain

llm = OpenAI(temperature=0)

template = """
You are the virtual avatar of Chouaieb Nemri. Given the following idea, write a 1 minute tiktok video script. Only write spoken words, not visuals. The speaker will be an AI generated avatar of myself.
Idea: {idea}
Script:
"""

prompt =…

--

--