-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.py
More file actions
125 lines (113 loc) · 3.41 KB
/
Config.py
File metadata and controls
125 lines (113 loc) · 3.41 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import os
import re
import shutil
from pathlib import Path
from turtle import width, speed, hideturtle
class _VideoElements:
lesson_names = (
"Znajdowanie_liczby_niewymiernej",
# "Mnożenie_ułamków",
# "Dzielenie_ułamków",
# "Dodawanie_ułamków",
# "Odejmowanie_ułamków",
# "Skracanie_ułamków",
# "Ułamki",
)
final_video_name = "{}_{}.mp4".format
class _AudioElements:
similarity_boost = 1
stability = 1
style = 0
model_id = "eleven_multilingual_v1"
voice_id = "2EiwWnXFnvU5JabPnv8n"
model = "tts-1"
voice = "alloy"
class Config(_VideoElements, _AudioElements):
default_english = "en-gb"
base_language = "pl"
languages = (
"en",
"pl",
"uk",
)
font_size = 12
font_path = "DejaVuSans"
color = "black"
default_height = 100
default_width = 50
symbol_write_speed = 10
minimal_border_width = 7
line_width = 3
width(line_width)
speed(0)
hideturtle()
start_x = -640
# start_x = -300
start_y = 280
# debug = True
debug = False
api_forbidden = True
# api_forbidden = False
# publish = True
publish = False
root = Path(__file__).parent
image_format = ".jpg"
images = root / "images"
output_videos = root / "output_videos"
output_audios = root / "output_audios"
last_frames = root / "last_frames"
final_videos = root / "final_videos"
scripts_package = root / "scripts"
translations = root / "translations"
audio_paths = root / "audio_paths.json"
temporary_files = root / "temporary_files"
temporary_picture = temporary_files / ".ps"
temp_translations = temporary_files / "translations.json"
first_frames = temporary_files / "first_frames"
temp_filename = str(temporary_files / ".mp4")
temp_audio_paths = temporary_files / "audio_paths.json"
tokens = root / "api_keys"
deepL_token = tokens.joinpath("deepL_token").read_text()
open_ai_token = tokens.joinpath("open_ai_token").read_text()
elevenlabs_api_key = tokens.joinpath("elevenlabs").read_text()
youtube_api_file = tokens.joinpath("google_client.json")
youtube_auth = tokens.joinpath("upload_video.py-oauth2.json")
os.environ.setdefault("OPENAI_API_KEY", open_ai_token)
temporary_files.mkdir(exist_ok=True)
tokens.mkdir(exist_ok=True)
output_videos.mkdir(exist_ok=True)
images.mkdir(exist_ok=True)
last_frames.mkdir(exist_ok=True)
first_frames.mkdir(exist_ok=True)
shutil.rmtree(output_videos)
shutil.rmtree(images)
shutil.rmtree(last_frames)
shutil.rmtree(first_frames)
final_videos.mkdir(exist_ok=True)
output_videos.mkdir(exist_ok=True)
output_audios.mkdir(exist_ok=True)
last_frames.mkdir(exist_ok=True)
first_frames.mkdir(exist_ok=True)
images.mkdir(exist_ok=True)
translations.mkdir(exist_ok=True)
@staticmethod
def audio_name_normalization(text: str) -> str:
polish_to_english = {
"ą": "a",
"ć": "c",
"ę": "e",
"ł": "l",
"ń": "n",
"ó": "o",
"ś": "s",
"ż": "z",
"ź": "z",
" ": "_",
}
return (
"".join(
polish_to_english.get(letter, letter)
for letter in re.sub(r"[,.?!]", "", text.strip()).lower()
)
+ ".mp3"
)