PulseAudio). Some people might find it for the ongoing lockdown.
Some VoIP software have builtin support for push-to-talk. In this mode, a global keyboard hotkey must be be held while speaking. This is quite useful when in a noisy environment and/or with suboptimal mics.
Some programs with support for this:
Most programs don't support this. This is especially true for browser-based VoIP software because as there is currently not web API (AFAIU) ro register a global keyboard hotkey1.
So I wrote two Python scripts for PulseAudio.
The first one implements push-to-talk based on some keyboard key. (i.e. you have to hold the key while you are talking):
pushtotalk --key "Home"
It's intended for PulseAudio and X11 but it should be quite easy to adapt this to other sound and GUI systems.
The second one just toggles the mute state of the default PulseAudio source and provides a visual feedback (notification). It's intended to be bound to some global keyboard hotkey.
For example using a script based on keybinder:
keybinder "<Control>m" pulse-mute-toggle
Simply toggling the audio source can be done with:
pactl set-sink-mute @DEFAULT_SOURCE@ toggle
Getting the notification of the state is important because otherwise you might end being in the wrong state. There is no
pactl get-sink-mute @DEFAULT_SOURCE@ command which is why it's not an absolutely straightforward shell script2.
This is why this feature is apparently available on the native Discord application but not on the web one. ↩
It can be done by:
pacmd list-sourcesor similar (which is cumbersome);
I decided to use the D-Bus interface (which is sadly not enabled by default). ↩