-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.py
146 lines (119 loc) · 6.26 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import os
import webbrowser
import customtkinter as ctk
from PIL import Image
from src.logic.settings import SettingsHandler
from src.ui.add_subtitles import AddSubtitlesUI
from src.ui.live_transcribe import LiveTranscribeUI
from src.ui.settings import SettingsUI
from src.ui.style import FONTS
from src.ui.transcribe import TranscribeUI
from src.ui.translate import TranslateUI
current_path = os.path.dirname(os.path.realpath(__file__))
icon_path = f"{current_path}{os.path.sep}assets{os.path.sep}icons{os.path.sep}"
icons = {
"logo": ctk.CTkImage(dark_image=Image.open(f"{icon_path}logo.png"),
light_image=Image.open(f"{icon_path}logo.png"), size=(50, 50)),
"close": ctk.CTkImage(dark_image=Image.open(f"{icon_path}close_dark.png"),
light_image=Image.open(f"{icon_path}close_light.png"), size=(30, 30)),
"audio_file": ctk.CTkImage(dark_image=Image.open(f"{icon_path}audio_file_dark.png"),
light_image=Image.open(f"{icon_path}audio_file_light.png"),
size=(30, 30)),
"translation": ctk.CTkImage(dark_image=Image.open(f"{icon_path}translation_dark.png"),
light_image=Image.open(f"{icon_path}translation_light.png"),
size=(30, 30)),
"microphone": ctk.CTkImage(dark_image=Image.open(f"{icon_path}microphone_dark.png"),
light_image=Image.open(f"{icon_path}microphone_light.png"),
size=(30, 30)),
"subtitles": ctk.CTkImage(dark_image=Image.open(f"{icon_path}subtitles_dark.png"),
light_image=Image.open(f"{icon_path}subtitles_light.png"),
size=(30, 30)),
"paypal": ctk.CTkImage(dark_image=Image.open(f"{icon_path}paypal_dark.png"),
light_image=Image.open(f"{icon_path}paypal_light.png"), size=(30, 30)),
"settings": ctk.CTkImage(dark_image=Image.open(f"{icon_path}settings_dark.png"),
light_image=Image.open(f"{icon_path}settings_light.png"),
size=(30, 30)),
"help": ctk.CTkImage(dark_image=Image.open(f"{icon_path}help_dark.png"),
light_image=Image.open(f"{icon_path}help_light.png"), size=(30, 30)),
"github": ctk.CTkImage(dark_image=Image.open(f"{icon_path}github_dark.png"),
light_image=Image.open(f"{icon_path}github_light.png"), size=(30, 30))
}
logo = f"{icon_path}logo.ico"
btn = {
"width": 280,
"height": 116,
"text_color": ("#FFFFFF", "#DFE1E5"),
"compound": "left",
"font": ("Inter", 16)
}
secondary_btn = {
"width": 280,
"height": 100,
"fg_color": ("#221D21", "#2B2D30"),
"hover": False,
"border_width": 0,
"text_color": ("#FFFFFF", "#DFE1E5"),
"compound": "left",
"font": ("Inter", 16)
}
link_btn = {
"width": 140,
"height": 80,
"fg_color": "transparent",
"hover_color": ("#D3D5DB", "#2B2D30"),
"border_color": ("#D3D5DB", "#2B2D30"),
"border_width": 2,
"text_color": ("#000000", "#DFE1E5"),
"compound": "left",
"font": ("Inter", 16)
}
def help_link():
webbrowser.open("https://github.com/rudymohammadbali/Whisper-Transcriber/discussions/categories/q-a")
def github_link():
webbrowser.open("https://github.com/rudymohammadbali")
def paypal_link():
webbrowser.open("https://www.paypal.com/paypalme/iamironman0")
class Testing(ctk.CTk):
def __init__(self):
super().__init__()
self.geometry("620x720")
self.resizable(False, False)
self.iconbitmap(logo)
self.title("Whisper Transcriber")
settings_handler = SettingsHandler()
settings = settings_handler.load_settings()
theme = settings.get("theme")
color_theme = settings.get("color_theme")
ctk.set_appearance_mode(theme)
ctk.set_default_color_theme(color_theme)
self.main_ui()
def main_ui(self):
title = ctk.CTkLabel(self, text="Welcome to Whisper Transcriber", text_color=("#000000", "#DFE1E5"),
font=FONTS["title_bold"], image=icons["logo"], compound="top")
title.grid(row=0, column=0, padx=20, pady=20, sticky="nsew", columnspan=2)
label = ctk.CTkLabel(self, text="Select a Service", text_color=("#000000", "#DFE1E5"), font=FONTS["subtitle"])
label.grid(row=1, column=0, padx=20, pady=20, sticky="w")
btn_1 = ctk.CTkButton(self, text="Transcribe Audio", **btn, image=icons["audio_file"],
command=lambda: TranscribeUI(parent=self))
btn_1.grid(row=2, column=0, padx=(20, 10), pady=10, sticky="nsew")
btn_2 = ctk.CTkButton(self, text="Translate Audio", **btn, image=icons["translation"],
command=lambda: TranslateUI(parent=self))
btn_2.grid(row=2, column=1, padx=(10, 20), pady=10, sticky="nsew")
btn_3 = ctk.CTkButton(self, text="Live Transcriber", **btn, image=icons["microphone"],
command=lambda: LiveTranscribeUI(parent=self))
btn_3.grid(row=3, column=0, padx=(20, 10), pady=10, sticky="nsew")
btn_4 = ctk.CTkButton(self, text="Add Subtitle", **btn, image=icons["subtitles"],
command=lambda: AddSubtitlesUI(parent=self))
btn_4.grid(row=3, column=1, padx=(10, 20), pady=10, sticky="nsew")
btn_5 = ctk.CTkButton(self, text="Settings", font=("Inter", 16), text_color=("#FFFFFF", "#DFE1E5"), width=280,
height=100, image=icons["settings"], command=lambda: SettingsUI(parent=self))
btn_5.grid(row=4, column=0, padx=(20, 10), pady=20, sticky="nsew")
btn_6 = ctk.CTkButton(self, text="Support on PayPal", **secondary_btn, image=icons["paypal"],
command=paypal_link)
btn_6.grid(row=4, column=1, padx=(10, 20), pady=20, sticky="nsew")
btn_7 = ctk.CTkButton(self, text="Github", **link_btn, image=icons["github"], command=github_link)
btn_7.grid(row=5, column=0, padx=20, pady=20, sticky="nsew")
btn_8 = ctk.CTkButton(self, text="Help", **link_btn, image=icons["help"], command=help_link)
btn_8.grid(row=5, column=1, padx=20, pady=20, sticky="nsew")
app = Testing()
app.mainloop()