-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.py
105 lines (92 loc) · 4.21 KB
/
configuration.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import json
from typing import Literal
class Configuration:
def __init__(self) -> None:
with open("config/configuration.json") as file:
config = json.loads(file.read())
with open("config/config_thumbnail_with_text.json") as file:
config_thumbnail_with_text = json.loads(file.read())
self.output_dir = config["output_dir"]
self.background_videos_dir = config["background_videos_dir"]
self.tolerated_duration_offset = config["tolerated_duration_offset"]
self.intro_header: str = config["intro_header"]
self.intro_prompt: str = config["intro_prompt"]
self.outro_prompt: str = config["outro_prompt"]
self.video_title_prompt: str = config["video_title_prompt"]
self.background_video_volume: float = config["background_video_volume"]
self.init_video_text(config)
self.init_openai(config)
self.init_moviepy(config)
self.init_thumbnail(config_thumbnail_with_text)
def init_thumbnail(self, config_thumbnail_with_text):
self.thumbnail_subreddit_icon_size: int = config_thumbnail_with_text[
"thumbnail_subreddit_icon_size"
]
self.thumbnail_subreddit_text_size: int = config_thumbnail_with_text[
"thumbnail_subreddit_text_size"
]
self.thumbnail_subreddit_text_color: str = config_thumbnail_with_text[
"thumbnail_subreddit_text_color"
]
self.thumbnail_subreddit_text_font: str = config_thumbnail_with_text[
"thumbnail_subreddit_text_font"
]
self.thumbnail_main_text_size: int = config_thumbnail_with_text[
"thumbnail_main_text_size"
]
self.thumbnail_main_text_color: str = config_thumbnail_with_text[
"thumbnail_main_text_color"
]
self.thumbnail_main_text_font: str = config_thumbnail_with_text[
"thumbnail_main_text_font"
]
self.thumbnail_like_icon_size: int = config_thumbnail_with_text[
"thumbnail_like_icon_size"
]
self.thumbnail_like_text_size: int = config_thumbnail_with_text[
"thumbnail_like_text_size"
]
self.thumbnail_like_text_color: str = config_thumbnail_with_text[
"thumbnail_like_text_color"
]
self.thumbnail_like_text_font: str = config_thumbnail_with_text[
"thumbnail_like_text_font"
]
self.thumbnail_element_margin: int = config_thumbnail_with_text[
"thumbnail_element_margin"
]
self.thumbnail_background_color: str = config_thumbnail_with_text[
"thumbnail_background_color"
]
self.thumbnail_side_offset: float = config_thumbnail_with_text[
"thumbnail_side_offset"
]
self.thumbnail_default_subreddit_icon: str = config_thumbnail_with_text[
"thumbnail_default_subreddit_icon"
]
self.thumbnail_upvotes_icon: str = config_thumbnail_with_text[
"thumbnail_upvotes_icon"
]
self.thumbnail_comments_icon: str = config_thumbnail_with_text[
"thumbnail_comments_icon"
]
def init_video_text(self, config):
self.video_font: str = config["video_font"]
self.video_font_color: str = config["video_font_color"]
self.video_font_size: int = config["video_font_size"]
self.video_font_stroke_width: int = config["video_font_stroke_width"]
self.video_font_stroke_color: str = config["video_font_stroke_color"]
def init_moviepy(self, config):
self.video_fps: int = config["video_fps"]
self.write_video_preset: str = config["write_video_preset"]
self.num_threads: int = config["num_threads"]
def init_openai(self, config):
with open("config/secrets.json", "r") as file:
secrets = json.loads(file.read())
self.openai_api_key = secrets["openai_api_key"]
self.audio_api: Literal["openai"] = config["audio_api"]
if self.audio_api == "openai":
self.audio_model: Literal["tts-1", "tts-1-hd"] = config["audio_model"]
self.audio_voice: Literal[
"alloy", "echo", "fable", "onyx", "nova", "shimmer"
] = config["audio_voice"]