Spaces:
Running
Running
Upload 5 files
Browse files- .gitignore +6 -0
- LICENSE +21 -0
- README.md +81 -0
- app.py +94 -0
- requirements.txt +52 -0
.gitignore
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.logs/
|
2 |
+
venv/
|
3 |
+
__pycache__/
|
4 |
+
.DS_Store
|
5 |
+
|
6 |
+
.env
|
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2024 SamurAIGPT
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
README.md
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Faceless Video Generator
|
2 |
+
|
3 |
+
Faceless Video Generator is an AI-powered tool for creating engaging videos from any topic. By leveraging state-of-the-art AI for script generation, text-to-speech audio synthesis, and background video matching, this project generates complete videos with minimal user input.
|
4 |
+
|
5 |
+
## Features
|
6 |
+
|
7 |
+
- **Script Generation:** Automatically generates a script based on the provided topic.
|
8 |
+
- **Audio Synthesis:** Utilizes text-to-speech technology to generate high-quality audio narration.
|
9 |
+
- **Timed Captions:** Creates captions that align with the audio for accessibility and clarity.
|
10 |
+
- **Background Video Search:** Searches and fetches suitable background video clips via video search queries.
|
11 |
+
- **Video Rendering:** Combines the synthesized audio, captions, and background visuals to produce the final video output.
|
12 |
+
- **Gradio Interface:** Provides a user-friendly interactive interface for generating videos.
|
13 |
+
|
14 |
+
## Prerequisites
|
15 |
+
|
16 |
+
- Python 3.8 or later
|
17 |
+
- [Gradio](https://gradio.app/) for the web interface
|
18 |
+
- Required Python packages listed in `requirements.txt`
|
19 |
+
|
20 |
+
## Installation
|
21 |
+
|
22 |
+
1. **Clone the Repository:**
|
23 |
+
|
24 |
+
```bash
|
25 |
+
git clone https://github.com/yourusername/Faceless-video.git
|
26 |
+
cd Faceless-video
|
27 |
+
```
|
28 |
+
|
29 |
+
2. **Create a Virtual Environment (Recommended):**
|
30 |
+
|
31 |
+
```bash
|
32 |
+
python -m venv venv
|
33 |
+
source venv/bin/activate # On Linux/macOS
|
34 |
+
venv\Scripts\activate # On Windows
|
35 |
+
```
|
36 |
+
|
37 |
+
3. **Install Dependencies:**
|
38 |
+
|
39 |
+
```bash
|
40 |
+
pip install -r requirements.txt
|
41 |
+
```
|
42 |
+
|
43 |
+
4. **API Keys:**
|
44 |
+
|
45 |
+
- This project requires API keys for various services.
|
46 |
+
- Create a `.env` file in the project root directory.
|
47 |
+
- Add your API keys to the `.env` file as follows:
|
48 |
+
|
49 |
+
```
|
50 |
+
GROQ_API_KEY=your_groq_api_key
|
51 |
+
PEXELS_API_KEY=your_pexels_api_key
|
52 |
+
```
|
53 |
+
|
54 |
+
> **Note:** Ensure you have accounts and API keys for Groq, and Pexels.
|
55 |
+
|
56 |
+
## Usage
|
57 |
+
|
58 |
+
1. **Run the Gradio Interface:**
|
59 |
+
|
60 |
+
```bash
|
61 |
+
python app.py
|
62 |
+
```
|
63 |
+
|
64 |
+
2. **Access the Interface:**
|
65 |
+
|
66 |
+
- Open your web browser and go to the address provided in the console (usually `http://localhost:7860`).
|
67 |
+
|
68 |
+
3. **Generating Videos:**
|
69 |
+
|
70 |
+
- Enter the topic for the video.
|
71 |
+
- Click the "Generate Video" button.
|
72 |
+
- The script, audio, captions, and video will be generated automatically.
|
73 |
+
- The final video will be displayed in the interface.
|
74 |
+
|
75 |
+
## Configuration
|
76 |
+
|
77 |
+
You can configure various aspects of the video generation process by modifying the parameters in the Gradio interface or directly in the Python scripts.
|
78 |
+
|
79 |
+
- **Script Length:** Adjust the length of the generated script.
|
80 |
+
- **Voice Settings:** Customize the voice used for audio synthesis.
|
81 |
+
- **Video Clip Duration:** Set the duration of the background video clips.
|
app.py
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from openai import OpenAI
|
3 |
+
import os
|
4 |
+
import edge_tts
|
5 |
+
import json
|
6 |
+
import asyncio
|
7 |
+
import whisper_timestamped as whisper
|
8 |
+
from utility.script_generator import generate_script
|
9 |
+
from utility.audio_generator import generate_audio
|
10 |
+
from utility.timed_captions_generator import generate_timed_captions
|
11 |
+
from utility.background_video_generator import generate_video_url
|
12 |
+
from utility.render_engine import get_output_media
|
13 |
+
from utility.video_search_query_generator import getVideoSearchQueriesTimed, merge_empty_intervals
|
14 |
+
|
15 |
+
async def generate_video(topic, progress=gr.Progress()):
|
16 |
+
try:
|
17 |
+
# Ensure audio directory exists
|
18 |
+
os.makedirs("audio", exist_ok=True)
|
19 |
+
|
20 |
+
SAMPLE_FILE_NAME = os.path.join("audio", "audio_tts.wav")
|
21 |
+
VIDEO_SERVER = "pexel"
|
22 |
+
|
23 |
+
progress(0.1, desc="Generating script...")
|
24 |
+
response = generate_script(topic)
|
25 |
+
|
26 |
+
|
27 |
+
progress(0.3, desc="Generating audio...")
|
28 |
+
await generate_audio(response, SAMPLE_FILE_NAME)
|
29 |
+
|
30 |
+
progress(0.5, desc="Generating captions...")
|
31 |
+
timed_captions = generate_timed_captions(SAMPLE_FILE_NAME)
|
32 |
+
|
33 |
+
progress(0.6, desc="Generating search terms...")
|
34 |
+
search_terms = getVideoSearchQueriesTimed(response, timed_captions)
|
35 |
+
|
36 |
+
if search_terms is not None:
|
37 |
+
progress(0.7, desc="Fetching background videos...")
|
38 |
+
background_video_urls = generate_video_url(search_terms, VIDEO_SERVER)
|
39 |
+
background_video_urls = merge_empty_intervals(background_video_urls)
|
40 |
+
|
41 |
+
if background_video_urls is not None:
|
42 |
+
progress(0.9, desc="Rendering final video...")
|
43 |
+
video = get_output_media(SAMPLE_FILE_NAME, timed_captions, background_video_urls, VIDEO_SERVER)
|
44 |
+
return video, "Video generated successfully!"
|
45 |
+
|
46 |
+
return None, "Failed to generate video. No suitable background videos found."
|
47 |
+
|
48 |
+
except Exception as e:
|
49 |
+
return None, f"Error: {str(e)}"
|
50 |
+
|
51 |
+
# Create Gradio interface
|
52 |
+
def create_interface():
|
53 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
54 |
+
gr.Markdown(
|
55 |
+
"""
|
56 |
+
# AI Video Generator
|
57 |
+
Generate engaging videos from any topic using AI
|
58 |
+
"""
|
59 |
+
)
|
60 |
+
|
61 |
+
with gr.Row():
|
62 |
+
with gr.Column():
|
63 |
+
topic_input = gr.Textbox(
|
64 |
+
label="Enter Your Topic",
|
65 |
+
placeholder="E.g., The history of artificial intelligence",
|
66 |
+
lines=2
|
67 |
+
)
|
68 |
+
generate_btn = gr.Button("Generate Video", variant="primary")
|
69 |
+
|
70 |
+
with gr.Column():
|
71 |
+
output_video = gr.Video(label="Generated Video")
|
72 |
+
status_text = gr.Textbox(label="Status", interactive=False)
|
73 |
+
|
74 |
+
generate_btn.click(
|
75 |
+
fn=generate_video,
|
76 |
+
inputs=[topic_input],
|
77 |
+
outputs=[output_video, status_text]
|
78 |
+
)
|
79 |
+
|
80 |
+
gr.Markdown(
|
81 |
+
"""
|
82 |
+
### How it works:
|
83 |
+
1. Enter a topic you want to create a video about
|
84 |
+
2. Click 'Generate Video'
|
85 |
+
3. Wait while the AI generates the script, audio, and matches appropriate visuals
|
86 |
+
4. Download your finished video!
|
87 |
+
"""
|
88 |
+
)
|
89 |
+
|
90 |
+
return demo
|
91 |
+
|
92 |
+
if __name__ == "__main__":
|
93 |
+
demo = create_interface()
|
94 |
+
demo.launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiohttp==3.9.5
|
2 |
+
aiosignal==1.3.1
|
3 |
+
annotated-types==0.7.0
|
4 |
+
anyio==4.4.0
|
5 |
+
attrs==23.2.0
|
6 |
+
certifi==2024.7.4
|
7 |
+
charset-normalizer==3.3.2
|
8 |
+
Cython==3.0.10
|
9 |
+
decorator==4.4.2
|
10 |
+
distro==1.9.0
|
11 |
+
dtw-python==1.5.1
|
12 |
+
edge-tts==6.1.12
|
13 |
+
filelock==3.14.0
|
14 |
+
frozenlist==1.4.1
|
15 |
+
fsspec==2024.6.0
|
16 |
+
h11==0.14.0
|
17 |
+
httpcore==1.0.5
|
18 |
+
httpx==0.27.0
|
19 |
+
idna==3.7
|
20 |
+
imageio==2.34.1
|
21 |
+
imageio-ffmpeg==0.5.1
|
22 |
+
Jinja2==3.1.4
|
23 |
+
llvmlite==0.42.0
|
24 |
+
MarkupSafe==2.1.5
|
25 |
+
more-itertools==10.2.0
|
26 |
+
moviepy==1.0.3
|
27 |
+
mpmath==1.3.0
|
28 |
+
multidict==6.0.5
|
29 |
+
networkx==3.3
|
30 |
+
numba==0.59.1
|
31 |
+
numpy==1.26.4
|
32 |
+
openai==1.31.1
|
33 |
+
openai-whisper==20231117
|
34 |
+
pillow==10.3.0
|
35 |
+
proglog==0.1.10
|
36 |
+
pydantic==2.7.3
|
37 |
+
pydantic_core==2.18.4
|
38 |
+
regex==2024.5.15
|
39 |
+
requests==2.32.3
|
40 |
+
scipy==1.13.1
|
41 |
+
sniffio==1.3.1
|
42 |
+
sympy==1.12.1
|
43 |
+
tiktoken==0.7.0
|
44 |
+
torch==2.3.1
|
45 |
+
tqdm==4.66.4
|
46 |
+
typing_extensions==4.12.1
|
47 |
+
urllib3==2.2.1
|
48 |
+
whisper-timestamped==1.15.4
|
49 |
+
yarl==1.9.4
|
50 |
+
groq==0.11.0
|
51 |
+
gradio
|
52 |
+
pydub
|