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