feat: add optional push-to-talk hold mode#26
feat: add optional push-to-talk hold mode#26mattlgroff wants to merge 1 commit intoknowall-ai:mainfrom
Conversation
|
Apologies for the delay, I missed the notification. |
There was a problem hiding this comment.
Pull request overview
This PR adds an optional push-to-talk mode to Turbo Whisper, allowing users to hold the hotkey to record and release to stop, in addition to the existing toggle behavior. The feature is disabled by default to preserve backward compatibility.
Changes:
- Added
push_to_talkboolean configuration option (defaults to False) - Extended hotkey manager infrastructure to support separate press and release callbacks
- Updated main application logic to handle push-to-talk mode by starting recording on key press and stopping on key release
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/turbo_whisper/config.py | Added push_to_talk boolean field with clear documentation |
| src/turbo_whisper/hotkey.py | Added on_deactivate callback parameter to hotkey managers; implemented release event handling in HotkeyManager with _combo_active state tracking |
| src/turbo_whisper/main.py | Added _on_hotkey_activate and _on_hotkey_deactivate methods with mode-specific logic; conditionally pass callbacks based on push_to_talk setting |
| config.example.json | Added push_to_talk: false to example configuration |
| README.md | Updated documentation to show both toggle and hold-to-talk modes with examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def __init__( | ||
| self, | ||
| hotkey_combo: list[str], | ||
| on_activate: Callable[[], None], | ||
| on_deactivate: Callable[[], None] | None = None, | ||
| ): | ||
| """Initialize portal hotkey manager.""" | ||
| # Import here to make dependencies optional | ||
| import dbus | ||
| from dbus.mainloop.glib import DBusGMainLoop | ||
| from gi.repository import GLib | ||
|
|
||
| self.callback = callback | ||
| self.on_activate = on_activate | ||
| self.on_deactivate = on_deactivate |
There was a problem hiding this comment.
The on_deactivate parameter is accepted but never used in the PortalHotkeyManager implementation. This could be confusing for users who enable push-to-talk mode on systems using the portal backend, as the release event will never fire. Consider adding a comment in the __init__ method documenting that on_deactivate is ignored by this backend, or logging a warning when the manager is initialized with a non-None on_deactivate callback.
| manager = PortalHotkeyManager(hotkey_combo, on_activate, on_deactivate) | ||
| print("Using xdg-desktop-portal for global hotkeys (Wayland)") | ||
| if on_deactivate: | ||
| print("Portal backend does not support release events; using press-only behavior") |
There was a problem hiding this comment.
The warning message "Portal backend does not support release events; using press-only behavior" is printed when on_deactivate is provided, but this message doesn't clearly explain the user-facing consequence. When push-to-talk mode is enabled with the portal backend, recording won't stop on key release, which defeats the purpose of push-to-talk. Consider making this warning more explicit, such as: "Warning: Portal backend does not support push-to-talk mode (no key release events). Recording will only start on key press."
| print("Portal backend does not support release events; using press-only behavior") | |
| print( | |
| "Warning: Portal backend does not support push-to-talk mode " | |
| "(no key release events). Recording will only start on key press." | |
| ) |
Summary
push_to_talkconfig (falseby default) to support hold-to-talk behavior without changing existing toggle behavior.push_to_talk=truestarts recording on key-down and stops on key-up (including single-key bindings like[\"alt\"]).Why
On Ubuntu Wayland I needed a true hold-to-talk interaction (press and hold to record, release to finalize) instead of only press-to-toggle. This adds that behavior behind config so existing users keep current behavior.
Risks
push_to_talk=truemay effectively behave as press-only when portal is used.alt) can have UX side effects depending on app/desktop behavior.Relation To Other PR
This is paired with a separate Wayland hotkey backend PR. Together they gave me reliable hold-to-talk + typing on Ubuntu Wayland.
Validation
python3 -m py_compile src/turbo_whisper/config.py src/turbo_whisper/hotkey.py src/turbo_whisper/main.pyhotkey=[\"alt\"]andpush_to_talk=true.Note
I couldn't find a
CONTRIBUTING.md, so I kept this scoped and conservative. If you'd like a different split/style I can adjust.