The Video Generator app creates video content based on given story prompts. It leverages LeonardoAI API for image generation and ElevenlabsAPI for voice and GPT4 for writing small stories. It generates everything automatically in a few seconds to generate images and voiceovers. The app then combines these elements, adding text and background music to generate a final video. You can see a working example video here: https://drive.google.com/file/d/1ZPxZwSx4nt9OKAaPQwfZuiwAWM-h-2bT/view
- Set up your environment variables in a
.envfile in the root directory. This file should contain yourLEONARDO_API_KEYandELEVEN_API_KEY. - Modify the
storyandpromptslists instory_and_prompts.pyas required. - Run
main.pyto generate the video based on the story and prompts provided.
dotenv: For loading environment variables.requests: For making HTTP requests to external services.PIL: For image manipulation.moviepy: For video generation and editing.pydub: For audio manipulation.elevenlabs: For generating voiceovers.natsorted: For natural sorting of files.
Generates images based on prompts using the Leonardo service.
__init__(): Initializes the class and sets the Leonardo API key._generate_image(prompt: str): Generates an image for a given prompt._generate_images(prompts: list): Generates multiple images for a list of prompts._download_image(generationId: str, image_name: str): Downloads an image by its generation ID and saves it._download_images(): Downloads all generated images.run(prompts: list): Generates and downloads images for a list of prompts.
Combines images, voiceovers, and text to produce video clips.
__init__(input_images: list, input_voiceovers: list, story: list): Initializes the class.- Various private methods to add text to images, voiceovers to images, and combine multiple video clips.
run(background_music: str, output_path: str): Generates small video clips and then combines them with background music to produce the final video.
Generates voiceovers based on story text using the Eleven Labs service.
__init__(): Initializes the class and sets the Eleven Labs API key.generate_voiceover(audio_text: str, voiceover_name: str): Generates a voiceover for a given text.generate_voiceovers(story_list): Generates multiple voiceovers for a list of storylines.
Provides utility functions for the main app.
generate_all_voiceovers(story: list): Generates voiceovers for the entire story.generate_all_images(prompts: list): Generates images for all prompts.get_files(directory, extension='.jpg'): Returns a naturally sorted list of files with a given extension from a directory.
Main execution file for the app.
- Sets up the environment variables.
- Generates voiceovers and images based on the
storyandprompts. - Combines the generated content into a final video.
Contains the story and prompts data lists. Modify these lists as required to generate content based on different stories and image prompts.