brailcom / speechd

Common high-level interface to speech synthesis
GNU General Public License v2.0
228 stars 65 forks source link

Audio ducking for media? #880

Open sthibaul opened 7 months ago

sthibaul commented 7 months ago

Is your feature request related to a problem? Please describe.

Inferred from @eeejay feedback: When e.g. listening to music, and suddenly a notification comes, we'd want the music to get lower so we can hear the notification, but not pause the music, since the notification could be a minor thing.

Describe the solution you'd like

SD could use the mixer to duck the audio of other applications.

I'm wondering if SD should just silent everything else, or we'd want some filtering?

eeejay commented 7 months ago

I have been thinking about this, and I think it should be implemented in Pipewire as an option. Pipewire should use the media roles to know which streams to duck when another one is playing. Specifically, if a stream with a role of Accessibility starts, other streams should duck. There are implementation questions I can't answer yet, like what is the lifetime of a stream, do they live the entire app lifetime or to they come and go with each sprite or utterance? If the former, is there some kind of notification when they are playing? But I think this should be a feature request in Pipewire.

eeejay commented 7 months ago

I asked around and it looks like wireplumber, the policy manager for pipewire does indeed support this. Shipping this on desktop and allowing users to enable this is another story: https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/features.html#policies

sthibaul commented 7 months ago

I asked around and it looks like wireplumber, the policy manager for pipewire does indeed support this. Shipping this on desktop and allowing users to enable this is another story: https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/features.html#policies

Debian for instance pulls wireplumber when pipewire is installed.

sthibaul commented 7 months ago

I have been thinking about this, and I think it should be implemented in Pipewire as an option. Pipewire should use the media roles to know which streams to duck when another one is playing. Specifically, if a stream with a role of Accessibility starts, other streams should duck. There are implementation questions I can't answer yet, like what is the lifetime of a stream, do they live the entire app lifetime or to they come and go with each sprite or utterance? If the former, is there some kind of notification when they are playing? But I think this should be a feature request in Pipewire.

spd streams typically live all along the module liveness

sthibaul commented 3 weeks ago

spd streams typically live all along the module liveness

We can however pause them as appropriate