diff --git a/utils/__pycache__/text_to_mic.cpython-312.pyc b/utils/__pycache__/text_to_mic.cpython-312.pyc index 77126aa..2bfee42 100644 Binary files a/utils/__pycache__/text_to_mic.cpython-312.pyc and b/utils/__pycache__/text_to_mic.cpython-312.pyc differ diff --git a/utils/text_to_mic.py b/utils/text_to_mic.py index 1cc6b02..f7a6d15 100644 --- a/utils/text_to_mic.py +++ b/utils/text_to_mic.py @@ -55,8 +55,8 @@ class TextToMic(tk.Tk): self.BASE_WIDTH = 590 self.BASE_HEIGHT_WITH_BANNER = 860 self.BASE_HEIGHT_NO_BANNER = 700 - self.COLLAPSED_HEIGHT_WITH_BANNER = 622 - self.COLLAPSED_HEIGHT_NO_BANNER = 510 + self.COLLAPSED_HEIGHT_WITH_BANNER = 630 + self.COLLAPSED_HEIGHT_NO_BANNER = 512 # Initial window geometry self.geometry(f"{self.BASE_WIDTH}x{self.BASE_HEIGHT_WITH_BANNER}") @@ -172,7 +172,7 @@ class TextToMic(tk.Tk): settings_menu = Menu(self.menubar, tearoff=0) self.menubar.add_cascade(label="Settings", menu=settings_menu) settings_menu.add_command(label="Change API Key", command=self.change_api_key) - settings_menu.add_command(label="ChatGPT Manipulation", command=self.chat_gpt_settings) + settings_menu.add_command(label="AI Copy Editing", command=self.chat_gpt_settings) settings_menu.add_command(label="Hotkey Settings", command=self.show_hotkey_settings) settings_menu.add_command(label="Manage Tone Presets", command=self.show_tone_presets_manager) @@ -356,12 +356,12 @@ class TextToMic(tk.Tk): # Text to Read section with proper layout text_read_frame = ttk.Frame(main_frame) - text_read_frame.grid(column=0, row=4, columnspan=2, sticky="ew", pady=(0, 10)) + text_read_frame.grid(column=0, row=4, columnspan=2, sticky="ew", pady=(10, 0)) text_read_frame.columnconfigure(0, weight=1) # Left side expands text_read_frame.columnconfigure(1, weight=0) # Right side fixed width - # Text to Read label - ttk.Label(text_read_frame, text="Text to Read:").grid(column=0, row=0, sticky=tk.W) + # Text to Read label - Updated to match other section titles + ttk.Label(text_read_frame, text="Text to Read", font=("Arial", 10, "bold")).grid(column=0, row=0, sticky=tk.W, pady=(0, 10)) # Create a frame to contain the dropdown and save button save_frame = ttk.Frame(text_read_frame) @@ -387,6 +387,24 @@ class TextToMic(tk.Tk): self.text_input.configure(bg="white", fg=text_color, insertbackground=text_color, wrap=tk.WORD) self.text_input.grid(column=0, row=5, columnspan=2, pady=(0, 20), sticky="nsew") # Proper spacing + # Add a status frame at the bottom of the text input with white background + status_frame = ttk.Frame(main_frame, style='White.TFrame') + status_frame.grid(column=0, row=5, columnspan=2, sticky=(tk.S, tk.E), pady=(0, 25)) + + # Create a custom style for the white frame + self.style.configure('White.TFrame', background='white') + + # Status indicator showing if editing is enabled + status_text = "AI Copyediting Disabled" + if settings.get("chat_gpt_completion", False): + if settings.get("auto_apply_ai_to_recording", False): + status_text = f"AI Copyediting Enabled (Auto) - {settings.get('model', self.default_model)}" + else: + status_text = f"AI Copyediting Enabled (Manual) - {settings.get('model', self.default_model)}" + + self.editing_status = ttk.Label(status_frame, text=status_text, foreground="#888888", font=("Arial", 8, "italic"), background="white") + self.editing_status.pack(side=tk.RIGHT, padx=5) + # Create a frame for the buttons to allow for better styling button_frame = ttk.Frame(main_frame) button_frame.grid(column=0, row=6, columnspan=2, sticky="ew", pady=(0, 20)) @@ -976,42 +994,62 @@ Please also make sure you read the Terms of use and licence statement before usi def chat_gpt_settings(self): settings = self.load_settings() settings_window = tk.Toplevel(self) - settings_window.title("ChatGPT Manipulation Settings") + settings_window.title("AI Copy Editing Settings") settings_window.grab_set() # Grab the focus on this toplevel window + settings_window.geometry("600x420") # Slightly larger to accommodate explanation text main_frame = ttk.Frame(settings_window, padding="10") main_frame.grid(column=0, row=0, sticky=(tk.W, tk.E, tk.N, tk.S)) + settings_window.columnconfigure(0, weight=1) + settings_window.rowconfigure(0, weight=1) + main_frame.columnconfigure(1, weight=1) # Make the second column expandable # Use the ttk style for uniformity style = ttk.Style() style.theme_use('clam') + # Add explanation text at the top + explanation_text = "This feature allows automatic editing of text using AI. When enabled, text will be refined according to your rules below. Please be aware that enabling this setting will increase the latency of the application." + + explanation_label = ttk.Label(main_frame, text=explanation_text, wraplength=550) + explanation_label.grid(row=0, column=0, columnspan=2, sticky=tk.W, pady=(0, 10)) + + # Move the checkbox to the second column to align with other input fields enable_completion = tk.BooleanVar(value=settings.get("chat_gpt_completion", False)) - ttk.Checkbutton(main_frame, text="Enable ChatGPT Completion", variable=enable_completion).grid(row=0, column=1, sticky=tk.W, pady=2) - - # Model selection# - + ttk.Label(main_frame, text="Enable AI Copy Editing:").grid(row=1, column=0, sticky=tk.W, pady=2) + ttk.Checkbutton(main_frame, text="", variable=enable_completion).grid(row=1, column=1, sticky=tk.W, pady=2) + # Model selection model_var = tk.StringVar(value=settings.get("model", self.default_model)) - ttk.Label(main_frame, text="Model:").grid(row=1, column=0, sticky=tk.W, pady=2) + ttk.Label(main_frame, text="Model:").grid(row=2, column=0, sticky=tk.W, pady=2) model_menu = ttk.OptionMenu(main_frame, model_var, model_var.get(), *self.available_models) - model_menu.grid(row=1, column=1, sticky=tk.W, pady=2) + model_menu.grid(row=2, column=1, sticky=(tk.W, tk.E), pady=2) - # Max Tokens selection + # Max Tokens selection - expanded options max_tokens_var = tk.IntVar(value=settings.get("max_tokens", 750)) - ttk.Label(main_frame, text="Max Tokens:").grid(row=2, column=0, sticky=tk.W, pady=2) - max_tokens_menu = ttk.OptionMenu(main_frame, max_tokens_var, 750, 100, 250, 500, 750, 1000, 1250, 1500) - max_tokens_menu.grid(row=2, column=1, sticky=tk.W, pady=2) + ttk.Label(main_frame, text="Max Tokens:").grid(row=3, column=0, sticky=tk.W, pady=2) + max_tokens_menu = ttk.OptionMenu(main_frame, max_tokens_var, max_tokens_var.get(), + 100, 250, 500, 750, 1000, 1250, 1500, 2000, 3000, 4000, 5000) + max_tokens_menu.grid(row=3, column=1, sticky=(tk.W, tk.E), pady=2) - # Prompt entry as a Text area - ttk.Label(main_frame, text="Prompt:").grid(row=3, column=0, sticky=tk.NW, pady=2) - prompt_entry = tk.Text(main_frame, height=4, width=40) - prompt_entry.insert('1.0', settings.get("prompt", "")) - prompt_entry.grid(row=3, column=1, sticky=tk.W, pady=2) + # Prompt entry renamed to "Copy Editing Rules" with a Text area + ttk.Label(main_frame, text="Copy Editing Rules:").grid(row=4, column=0, sticky=tk.NW, pady=2) + prompt_entry = tk.Text(main_frame, height=8, width=50) + + # Default prompt example if none exists + default_prompt = "Edit the text provided to ensure it has a clear, professional tone. Fix any grammatical errors, improve sentence structure, and maintain consistent formatting. Make the language concise and impactful while preserving the original meaning. Make sure to edit text only and do not reply to it." + + prompt_entry.insert('1.0', settings.get("prompt", default_prompt)) + prompt_entry.grid(row=4, column=1, sticky=(tk.W, tk.E), pady=2) - # Auto-apply checkbox + # Auto-apply checkbox - moved to second column with clear label auto_apply = tk.BooleanVar(value=settings.get("auto_apply_ai_to_recording", False)) - ttk.Checkbutton(main_frame, text="Auto Apply to Recorded Transcript", variable=auto_apply).grid(row=4, column=1, sticky=tk.W, pady=2) + ttk.Label(main_frame, text="Auto Apply to Recordings:").grid(row=5, column=0, sticky=tk.W, pady=2) + ttk.Checkbutton(main_frame, text="", variable=auto_apply).grid(row=5, column=1, sticky=tk.W, pady=2) + + # Add a label explaining the auto-apply setting + auto_apply_explanation = "When checked, recordings will be automatically copy edited according to your rules above" + ttk.Label(main_frame, text=auto_apply_explanation, foreground="#666666", wraplength=450).grid(row=6, column=1, sticky=tk.W, pady=(0, 10)) # Save Button save_btn = ttk.Button(main_frame, text="Save", command=lambda: self.save_chat_gpt_settings({ @@ -1021,12 +1059,23 @@ Please also make sure you read the Terms of use and licence statement before usi "auto_apply_ai_to_recording": auto_apply.get(), "max_tokens": max_tokens_var.get() })) - save_btn.grid(row=5, column=1, sticky=tk.W + tk.E, pady=10) + save_btn.grid(row=7, column=0, columnspan=2, sticky=tk.E, pady=10) def save_chat_gpt_settings(self, settings): self.save_settings_to_JSON(settings) messagebox.showinfo("Settings Updated", "Your settings have been saved successfully.") self.load_settings() # Refresh settings if needed elsewhere + + # Update the status indicator on the main screen with more specific information + status_text = "AI Copyediting Disabled" + if settings.get("chat_gpt_completion", False): + if settings.get("auto_apply_ai_to_recording", False): + status_text = f"AI Copyediting Enabled (Auto) - {settings.get('model', self.default_model)}" + else: + status_text = f"AI Copyediting Enabled (Manual) - {settings.get('model', self.default_model)}" + + if hasattr(self, 'editing_status'): + self.editing_status.config(text=status_text) def apply_ai(self, input_text=None):