-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathmain.py
77 lines (54 loc) · 1.85 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# utils.py
import asyncio
import json
import platform
from dotenv import find_dotenv, load_dotenv
from utils import *
# msg.py
import msg
# logger.py
from src.logger import setup_logger
# arg_parser.py
from src.arg_parser import parse_args
# video_creator.py
from src.video_creator import VideoCreator
# Default directory
HOME = Path.cwd()
# Logging
logger = setup_logger()
# JSON video file
video_json_path = HOME / 'video.json'
jsonData = json.loads(video_json_path.read_text(encoding='utf-8'))
#######################
# CODE #
#######################
async def main() -> bool:
console.clear() # Clear terminal
args = await parse_args()
videos = jsonData
for video in videos:
logger.debug('Creating video')
with console.status(msg.STATUS) as status:
load_dotenv(find_dotenv()) # Optional
console.log(
f"{msg.OK}Finish loading environment variables")
logger.info('Finish loading environment variables')
video_creator = VideoCreator(video, args)
video_creator.download_video()
video_creator.load_model()
video_creator.create_text()
await video_creator.text_to_speech()
video_creator.generate_transcription()
video_creator.select_background()
video_creator.integrate_subtitles()
if args.upload_tiktok:
video_creator.upload_to_tiktok()
console.log(f'{msg.DONE} {str(video_creator.mp4_final_video)}')
return 0
if __name__ == "__main__":
if platform.system() == 'Windows':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
sys.exit(0)