ILikeAI / AlwaysReddy

AlwaysReddy is a LLM voice assistant that is always just a hotkey away.
MIT License
621 stars 61 forks source link

Changed keyboard handler to AutoHotKey for better compatibility on Windows. #51

Closed j4byers closed 4 months ago

j4byers commented 4 months ago

The keyboard handler used before was breaking all sorts of keybinds I use, plus it didn't seem to have the ability to bind mouse buttons, so I adapted it and changed everything to use the ahk AutoHotKey Python wrapper. So far, it works seamlessly with my multitude of other hotkey scripts running. Obviously this is Windows-only, so perhaps you can merge and create an installer step to ask if the user is running Linux, which would revert to the original handler.

ILikeAI commented 4 months ago

Hey this looks super interesting I haven't heard AHK before. I'm curious is the current keyboard handler just messing with your existing AHK setup or other things to? For what I can see AHK is windows only so we would need to adjust this so that Linux and Mac users still use pynput

j4byers commented 4 months ago

Hey this looks super interesting I haven't heard AHK before. I'm curious is the current keyboard handler just messing with your existing AHK setup or other things to? For what I can see AHK is windows only so we would need to adjust this so that Linux and Mac users still use pynput

I use an extremely heavy autohotkey script that I've been working on and building out for a long time, which essentially converts every keyboard and mouse input to function as they do on MacOS. I switched from Mac to PC for my primary machine a couple of years ago, and I didn't feel like retraining my muscle memory. Ironically, after how long I've been working on it, I prob should have just learned, lol. It started out from a fork of a script that got basic MacOS keybinds down (https://github.com/rbreaves/kinto), then every time I noticed something was missing/different from my Mac, I got to work.

Then I started adding functionality that wasn't macos-based, but I wanted to have. Even before I found your repo, I had been using something similar built within AHK, which does almost the same thing, but without voice: highlight text, press hotkey to open up menu, select what to do with the text (e.g. send raw text to gpt35, translate using gpt4, etc), then get a response in a popup window.

image

It's modified from another AHK-based tool called ChatKey, but I essentially integrated the core logic.

Anyway, long story short... I originally was going to modify what I have into to work with triggered listening and spoken output until I saw your tool and said screw it, you've done all the hard work, and it's almost exactly what I needed. The only problem was that the keyboard handler you used completely obliterated my modifier hotkeys, which as you can imagine with the Mac->Windows thing, there are a LOT of (e.g. reversing some of my CTRL->CMD conversions sometimes 🤦🏽‍♂️).

I still would like to explore porting AlwaysReddy into native AHK -- I have all the API script done, I just need to integrate the microphone device/whisper, then pass the response voice to piper/sox and presto.

I'll let you know if I do it -- you might find it interesting. You can do a lot more with AutoHotKey than most users realize.

j4byers commented 4 months ago

Side note -- is anyone currently working on Gemini support, wake word activation and/or recording auto-stop? If not, I might take a stab at it (Gemini for sure) if I get some spare time, If there is a branch or a fork working on it, let me know.

Jobus0 commented 4 months ago

Thanks for sharing this! This AutoHotkey wrapper seems like a good idea since we're having some issues with the current solutions. Your AHK code should be re-implemented as a self-contained handler class though so it can be loaded as one of multiple options. I'm currently refactoring all the input stuff, so if you don't mind, I'd be happy to do that re-implementation instead of accepting this pull request as it would break Linux as-is.

I would also make a pynput-to-ahk hotkey translation layer so the pynput-style "shift+ctrl+r" defaults work on both.

Side note -- is anyone currently working on Gemini support, wake word activation and/or recording auto-stop? If not, I might take a stab at it (Gemini for sure) if I get some spare time, If there is a branch or a fork working on it, let me know.

Wake word and auto-stop is something that's been brought up before, but no one is working on it as far as I know. Both that and Gemini support would be great.

ILikeAI commented 4 months ago

Thanks for this PR, id never heard of AHK before but it seems to of fixed another issue with AlwaysReddy which is awesome. @Jobus0 has built on your PR and integrated it into a refactored input manager which uses AHK by default on windows!

Side note -- is anyone currently working on Gemini support, wake word activation and/or recording auto-stop? If not, I might take a stab at it (Gemini for sure) if I get some spare time, If there is a branch or a fork working on it, let me know.

That would be awesome! Wake word detection is something a few people have requested but i havent had a chance to look at yet. As far as what branch to use, the main one is the most up to date! If youre not in the discord feel free to jump in and chat there if you would like :)