savbell / whisper-writer

💬📝 A small dictation app using OpenAI's Whisper speech recognition model.
GNU General Public License v3.0
327 stars 52 forks source link

Using pynput instead of pyautogui #10

Closed uberkael closed 9 months ago

uberkael commented 1 year ago

Hi, Nice project!

I have a custom keyboard layout and PyAutoGUI can't handle some non-English keyboards (mine is not even a standard one) check here https://github.com/asweigart/pyautogui/issues/137. I did try some alternatives (like using keyboard that is already imported) but I settled with pynput. Because you were using some delay between keys I created a helper function but if for some reason it won't be needed it can be as simple as: pyinput_keyboard.type(transcribed_text)

I also had trouble with the sample rate (Linux Pipewire) but I solved it for another PR (maybe).

Thanks!

uberkael commented 1 year ago

The keyboard library requires to use root on Linux (at least). This can be avoided by replacing this line: keyboard.add_hotkey(config["activation_key"], on_shortcut) like here https://pynput.readthedocs.io/en/latest/keyboard.html#global-hotkeys

If this request (and pynput) is accepted it can help to deal with that.

savbell commented 9 months ago

Hi, thanks for your PR! Apologies for not reviewing it until now. I appreciate you fixing the issue with non-English keyboards! :)

I don't have the time to test on Linux (I created this project for my personal use and didn't expect anyone else to use it, haha!), but feel free to create another PR to change to using the pynput global hotkeys instead!