diff --git a/agent-mAId/main.py b/agent-mAId/main.py index af72905..5dd01be 100644 --- a/agent-mAId/main.py +++ b/agent-mAId/main.py @@ -1,14 +1,21 @@ import os -from groq import Groq +import sys import pyaudio import wave import pyautogui import keyboard import mouse +import threading +from groq import Groq +import pystray +from pystray import MenuItem as item +from PIL import Image +import ctypes # Constants API_KEY = "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" # Make sure to use your actual API key BUTTON = 'ctrl' # The keyboard button to listen for +AUTO_START_PATH = os.path.expanduser(r"~\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup") # For autostart # Initialize the Groq client client = Groq(api_key=API_KEY) @@ -50,6 +57,8 @@ def transcribe_audio(filename): response_format="json", # Optional temperature=0.0 # Optional ) + + # Access the transcription text using dot notation return transcription.text def simulate_keypress(text): @@ -73,5 +82,43 @@ def main(): print("Entering text...") simulate_keypress(transcribed_text) +def add_to_autostart(): + """Registers the app to autostart on login.""" + script_path = os.path.abspath(__file__) + shortcut_path = os.path.join(AUTO_START_PATH, "MyApp.lnk") + + # Use ctypes to create the shortcut (this is Windows specific) + shell = ctypes.windll.shell32 + shell.ShellExecuteW(None, "runas", "cmd.exe", f'/C mklink "{shortcut_path}" "{script_path}"', None, 1) + print("App added to autostart.") + +def quit_app(icon): + """Quit the tray application.""" + icon.stop() + sys.exit() + +def setup_tray_icon(): + """Setup system tray icon and menu.""" + # Create an icon image + icon_image = Image.new('RGB', (64, 64), color=(255, 0, 0)) # Red icon as an example + + # Define menu items for the tray + menu = ( + item('Register to Autostart', add_to_autostart), + item('Exit', lambda: quit_app(icon)) + ) + + # Create the tray icon + icon = pystray.Icon("my_app", icon_image, menu=pystray.Menu(*menu)) + + # Run the tray icon + icon.run() + if __name__ == "__main__": - main() \ No newline at end of file + # Start the tray icon in a separate thread so it doesn't block the main functionality + tray_thread = threading.Thread(target=setup_tray_icon) + tray_thread.daemon = True + tray_thread.start() + + # Run the main function + main() diff --git a/agent-mAId/output.wav b/agent-mAId/output.wav index 36842f9..b9dca44 100644 Binary files a/agent-mAId/output.wav and b/agent-mAId/output.wav differ