{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"
"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "fxiI_TSFJoUG"
},
"source": [
"### Steps for generating video from text\n",
"\n",
"1. Use openai to generate a video script from a topic\n",
"2. Use edgetts to pick a voice and create a audio based on the above generated script\n",
"3. Use whisper and get timed captions for the above audio\n",
"4. Now generate visual keywords for the video script using openai api\n",
"5. Fetch videos based on the above visual keywords using pexels api\n",
"6. Stich together the videos, audio and captions using Moviepy"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "6fkhqa92Cin_"
},
"source": [
"### Install python 3.11"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "meK-2tnywL_7"
},
"outputs": [],
"source": [
"!sudo apt-get update -y\n",
"!sudo apt-get install -y python3.11\n",
"!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1\n",
"!sudo update-alternatives --config python3\n",
"!sudo apt-get install -y python3.11-distutils\n",
"!wget https://bootstrap.pypa.io/get-pip.py\n",
"!python3.11 get-pip.py"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "T4_IZ9yOg1ez",
"outputId": "dfd4db16-0cfd-4e6a-950d-5dece90d722d"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cloning into 'Text-To-Video-AI'...\n",
"remote: Enumerating objects: 80, done.\u001b[K\n",
"remote: Counting objects: 100% (80/80), done.\u001b[K\n",
"remote: Compressing objects: 100% (36/36), done.\u001b[K\n",
"remote: Total 80 (delta 39), reused 71 (delta 34), pack-reused 0\u001b[K\n",
"Receiving objects: 100% (80/80), 1.24 MiB | 12.94 MiB/s, done.\n",
"Resolving deltas: 100% (39/39), done.\n"
]
}
],
"source": [
"!git clone https://github.com/SamurAIGPT/Text-To-Video-AI"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ZvqhgpZHg_02"
},
"outputs": [],
"source": [
"%cd Text-To-Video-AI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "wnj485rjCo0i"
},
"source": [
"### Install dependencies"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "i0tWUgm2hD-0"
},
"outputs": [],
"source": [
"!pip3.11 install -r requirements.txt"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ZTgjbem5Cwtx"
},
"source": [
"### Setup api keys"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1y66YFE9lHu0"
},
"outputs": [],
"source": [
"import os\n",
"\n",
"#for text generation, use openai or groq. groq model used: \"llama3-70b-8192\"\n",
"#note: use just one\n",
"os.environ[\"OPENAI_KEY\"]=\"openai-key\"\n",
"os.environ['GROQ_API_KEY'] = \"grog_api\"\n",
"\n",
"os.environ[\"PEXELS_KEY\"]=\"pexels-key\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "sgCT0PfUCzBB"
},
"source": [
"### Modify permissions for Imagemagick (workaround in colab)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "F9I5aBXpSHOn"
},
"outputs": [],
"source": [
"!apt install imagemagick &> /dev/null\n",
"!sed -i '/\n",
"