Push-to-talk in any application

| 🤔 | 👍 | 👎 |

Some scripts I wrote to enable system-wide push-to-talk (for X11 and PulseAudio). Some people might find it for the ongoing lockdown.

Some Voice over IP (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 to register a global keyboard hotkey1 as far as I know.

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.

Toggle audio source

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.

  1. This is why this feature is apparently available on the native Discord application but not on the web one. 

  2. It can be done by:

    • parsing the output of pacmd list-sources or similar (which is cumbersome);
    • relying on the native protocol;
    • use the PulseAudio D-Bus interface.

    I decided to use the D-Bus interface (which is sadly not enabled by default).