Working version

- audio/video files support added
This commit is contained in:
2025-09-17 00:59:43 +03:00
parent 7291b148e5
commit 414cb4d38e
6 changed files with 85 additions and 42 deletions
+24
View File
@@ -0,0 +1,24 @@
import customtkinter as ctk
class ToolTip(ctk.CTkToplevel):
def __init__(self, widget, text):
super().__init__()
self.withdraw()
self.overrideredirect(True)
self.attributes("-topmost", True)
self.label = ctk.CTkLabel(self, text=text, fg_color="gray20", corner_radius=6, padx=10, pady=5)
self.label.pack()
self.widget = widget
widget.bind("<Enter>", self.show_tooltip)
widget.bind("<Leave>", self.hide_tooltip)
def show_tooltip(self, event=None):
x = self.widget.winfo_rootx() + 20
y = self.widget.winfo_rooty() + 20
self.geometry(f"+{x}+{y}")
self.deiconify()
def hide_tooltip(self, event=None):
self.withdraw()
+18 -7
View File
@@ -11,6 +11,7 @@ from transcription.audio_transcription import AudioTranscription
from transcription.device_configuration import DeviceConfiguration
from transcription.torch_checker import check_torch
from ui.ui_log_handler import setup_ui_logger
from ui.tooltip import ToolTip
WINDOW_WIDTH = 900
WINDOW_HEIGHT = 650
@@ -101,6 +102,8 @@ class TranscriberApp(ctk.CTk):
ctrl_frame, text="Stop", command=self._stop_transcription, state="disabled"
)
self.stop_btn.pack(side="left", padx=10, pady=5)
# TODO: add unload model button here
# log box
self.log_box = scrolledtext.ScrolledText(
@@ -112,6 +115,7 @@ class TranscriberApp(ctk.CTk):
self.log_box.pack(padx=20, pady=10, expand=True, fill="both")
def _build_settings_tab(self):
# TODO: add tooltips here
pad = 20
### Model
@@ -175,20 +179,27 @@ class TranscriberApp(ctk.CTk):
path = filedialog.askopenfilename(
title="Select input audio file",
filetypes=[
("Audio files", "*.wav *.mp3 *.m4a *.flac"),
("Media files", "*.wav *.mp3 *.m4a *.flac *.ogg *.mp4 *.mkv *.avi"),
("Audio files", "*.wav *.mp3 *.m4a *.flac *.ogg"),
("Video files", "*.mp4 *.mkv *.avi"),
("All files", "*.*"),
],
]
)
if path:
self.input_file_var.set(path)
def _browse_output(self):
path = filedialog.asksaveasfilename(
title="Select output file",
defaultextension=".txt",
filetypes=[("Text files", "*.txt"), ("All files", "*.*")],
# TODO: add custom filename here
directory = filedialog.askdirectory(
title="Select output directory",
)
if path:
if directory:
input_name = os.path.basename(self.input_file_var.get())
name, _ = os.path.splitext(input_name)
# TODO: redo output_name logic maybe?
output_name = f"{"".join(name.split(".").pop())}.txt"
path = os.path.join(directory, output_name)
self.output_file_var.set(path)
def _check_torch(self):
+1 -1
View File
@@ -13,7 +13,7 @@ class UILogHandler(logging.Handler):
self.text_widget.see(tk.END)
# TODO: maybe some tqdm here, not in console?
# TODO: status should be here
def setup_ui_logger(text_widget: tk.Text, level=logging.INFO):
logger = logging.getLogger("UI_LOGGER")
logger.setLevel(level)