{"version": "https://jsonfeed.org/version/1", "title": "/dev/posts/ - Tag index - pulseaudio", "home_page_url": "https://www.gabriel.urdhr.fr", "feed_url": "/tags/pulseaudio/feed.json", "items": [{"id": "http://www.gabriel.urdhr.fr/2020/04/11/push-to-talk-in-any-application/", "title": "Push-to-talk in any application", "url": "https://www.gabriel.urdhr.fr/2020/04/11/push-to-talk-in-any-application/", "date_published": "2020-04-11T00:00:00+02:00", "date_modified": "2020-04-11T00:00:00+02:00", "tags": ["computer", "unix", "gui", "pulseaudio", "x11", "covid-19"], "content_html": "

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

\n

Some VoIP software have builtin support for push-to-talk.\nIn this mode, a global keyboard hotkey must be be held while speaking.\nThis is quite useful when in a noisy environment\nand/or with suboptimal mics.

\n

Some programs with support for this:

\n\n

Most programs don't support this.\nThis is especially true for browser-based VoIP software because as there is currently\nnot web API (AFAIU) ro register a global keyboard hotkey1.

\n

So I wrote two Python scripts for PulseAudio.

\n

Push-to-talk

\n

The first one\nimplements push-to-talk based on some keyboard key.\n(i.e. you have to hold the key while you are talking):

\n
pushtotalk --key \"Home\"\n
\n\n\n

It's intended for PulseAudio\nand X11 but it should be quite easy to adapt this to other sound and GUI systems.

\n

Toggle audio source

\n

The second one\njust toggles the mute state of the default PulseAudio source\nand provides a visual feedback (notification).\nIt's intended to be bound to some global keyboard hotkey.

\n

For example using a script\nbased on keybinder:

\n
keybinder \"<Control>m\" pulse-mute-toggle\n
\n\n\n

Simply toggling the audio source can be done with:

\n
pactl set-sink-mute @DEFAULT_SOURCE@ toggle\n
\n\n\n

Getting the notification of the state is important because otherwise you might\nend being in the wrong state.\nThere is no pactl get-sink-mute @DEFAULT_SOURCE@ command\nwhich is why it's not an absolutely straightforward shell script2.

\n
\n
\n
    \n
  1. \n

    This is why this feature is apparently available on the native Discord application\nbut not on the web one.\u00a0\u21a9

    \n
  2. \n
  3. \n

    It can be done by:

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

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

    \n
  4. \n
\n
"}]}