Skip to content

rhea164/text_to_video

Repository files navigation

🎬 AI-Powered Text-to-Video Generator
Transform a simple text prompt into a captivating video with AI-generated story, images, and audio.

🚀 Overview

This project automates the creation of engaging videos from text prompts. It uses OpenAI's GPT-3.5 to generate a story, OpenAI's Image API to visualize key moments, and combines these with audio narration into a final video.

text-to-video-generator.mp4

✨ Features

• 📝 Story Generation: OpenAI's GPT-3.5 crafts a narrative from your prompt.
• 🖼️ Image Creation: OpenAI's Image API generates visuals for story segments.
• 🔊 Audio Narration: Text-to-speech conversion (macOS say command).
• 🎥 Video Compilation: MoviePy combines images, captions, and audio.
• 🌐 Web Interface: Streamlit provides an easy-to-use web app.

🛠️ Tech Stack

Python: Core programming language.
OpenAI API:
   • gpt-3.5-turbo-instruct for story generation.
   • Image.create for image generation.
MoviePy: Video editing library.
FFmpeg: Audio conversion (AIFF to MP3).
Pillow (PIL): Image processing.
NumPy: Array operations for image handling.
Streamlit: Web app framework.

🔧 How It Works

1.app.py: Streamlit web interface.
•User enters a prompt.
•Calls text_generator.py and video_generator.py.
•Displays generated text and video.
2.text_generator.py: Takes a prompt, generates a story using GPT-3.5.
3.video_generator.py:
• Splits story into max 10 segments.
• For each segment:
   • OpenAI Image API creates an image.
   • say command narrates text (AIFF).
   • FFmpeg converts AIFF to MP3.
• MoviePy assembles images, captions, and audio.

🚦 Getting Started

  1. Clone this repository.
  2. Install Python dependencies:
    pip install -r requirements.txt
  3. Install system dependencies:
     macOS: brew install ffmpeg
     Ubuntu/Debian: sudo apt-get install ffmpeg
     Windows: Download from FFmpeg, add to PATH.
  4. Add your OpenAI API key
  5. Run the Streamlit app: streamlit run app.py
  6. open displayed URL and enter the prompt

Run: python text_generator.py
python video_generator.py

⚠️ Note for Non-macOS Users The audio narration uses macOS's say command. For other platforms, consider gTTS or pyttsx3.

🔍 Key Files

app.py: Streamlit web interface.
text_generator.py: Story generation.
video_generator.py: Image, audio, and video creation.
.env: Secure OpenAI API key storage.

🎓 Learning Points

Full-stack AI: OpenAI for text and images, system tools for audio.
Web Dev with AI: Integrating Streamlit for a user-friendly AI interface.
Security: Using python-dotenv for safe API key management.
Media Manipulation: Handling text, images, and audio with Python.

🤝 Contributing

Contributions welcome! Fork and submit a PR.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published