Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from openai import OpenAI
|
2 |
+
import os
|
3 |
+
import edge_tts
|
4 |
+
import json
|
5 |
+
import asyncio
|
6 |
+
import whisper_timestamped as whisper
|
7 |
+
from utility.script.script_generator import generate_script
|
8 |
+
from utility.audio.audio_generator import generate_audio
|
9 |
+
from utility.captions.timed_captions_generator import generate_timed_captions
|
10 |
+
from utility.video.background_video_generator import generate_video_url
|
11 |
+
from utility.render.render_engine import get_output_media
|
12 |
+
from utility.video.video_search_query_generator import getVideoSearchQueriesTimed, merge_empty_intervals
|
13 |
+
import argparse
|
14 |
+
|
15 |
+
if __name__ == "__main__":
|
16 |
+
parser = argparse.ArgumentParser(description="Generate a video from a topic.")
|
17 |
+
parser.add_argument("topic", type=str, help="The topic for the video")
|
18 |
+
|
19 |
+
args = parser.parse_args()
|
20 |
+
SAMPLE_TOPIC = args.topic
|
21 |
+
SAMPLE_FILE_NAME = "audio_tts.wav"
|
22 |
+
VIDEO_SERVER = "pexel"
|
23 |
+
|
24 |
+
response = generate_script(SAMPLE_TOPIC)
|
25 |
+
print("script: {}".format(response))
|
26 |
+
|
27 |
+
asyncio.run(generate_audio(response, SAMPLE_FILE_NAME))
|
28 |
+
|
29 |
+
timed_captions = generate_timed_captions(SAMPLE_FILE_NAME)
|
30 |
+
print(timed_captions)
|
31 |
+
|
32 |
+
search_terms = getVideoSearchQueriesTimed(response, timed_captions)
|
33 |
+
print(search_terms)
|
34 |
+
|
35 |
+
background_video_urls = None
|
36 |
+
if search_terms is not None:
|
37 |
+
background_video_urls = generate_video_url(search_terms, VIDEO_SERVER)
|
38 |
+
print(background_video_urls)
|
39 |
+
else:
|
40 |
+
print("No background video")
|
41 |
+
|
42 |
+
background_video_urls = merge_empty_intervals(background_video_urls)
|
43 |
+
|
44 |
+
if background_video_urls is not None:
|
45 |
+
video = get_output_media(SAMPLE_FILE_NAME, timed_captions, background_video_urls, VIDEO_SERVER)
|
46 |
+
print(video)
|
47 |
+
else:
|
48 |
+
print("No video")
|