Speech synthesis Firefox flatpak

Message “You can’t use speech synthesis because Speech Dispatcher won’t open.”
FF 124.0.2 from flathub
Silverblue 40
Do I really need to enable the service to make it work? Can’t find the socket under /run/user or /var/run/user . Thnx in advance.

× speech-dispatcherd.service - Speech-Dispatcher, common interface to speech synthesizers
     Loaded: loaded (/usr/lib/systemd/system/speech-dispatcherd.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: failed (Result: exit-code) since Mon 2024-04-08 10:03:57 -03; 41min ago
    Process: 17753 ExecStart=/usr/bin/speech-dispatcher -d -t 0 (code=exited, status=1/FAILURE)
        CPU: 8ms

Apr 08 10:03:57 biscoito systemd[1]: Starting speech-dispatcherd.service - Speech-Dispatcher, common interface to speech synthesizers...
Apr 08 10:03:57 biscoito speech-dispatcher[17753]: [Mon Apr  8 10:03:57 2024 : 325191] speechd: Speech Dispatcher 0.11.5 starting
Apr 08 10:03:57 biscoito speech-dispatcher[17753]: [Mon Apr  8 10:03:57 2024 : 325665] speechd: Can't create pid file in /root/.cache/speech-dispatcher/pid/speech-dispatcher.pid, wrong permissions?
Apr 08 10:03:57 biscoito speech-dispatcher[17753]: Can't create pid file in /root/.cache/speech-dispatcher/pid/speech-dispatcher.pid, wrong permissions?
Apr 08 10:03:57 biscoito systemd[1]: speech-dispatcherd.service: Control process exited, code=exited, status=1/FAILURE
Apr 08 10:03:57 biscoito systemd[1]: speech-dispatcherd.service: Failed with result 'exit-code'.
Apr 08 10:03:57 biscoito systemd[1]: Failed to start speech-dispatcherd.service - Speech-Dispatcher, common interface to speech synthesizers.

1 Like

I have a similar issue with Brave Browser, it seems that flatpak based application don’t have access to speech-dispatcher!
I hope there is a solution to this!

2 Likes

Hello @lucio ,
Welcome to :fedora: !
As this is a flatpak application it will likely require some tweaking for you to get it working properly. I would suggest to first install flatseal in order to get a good view of the current sandboxing level of FF as flatpak. Plus I would try to do an update of rpm-ostree since speech-dispatcher is now at version 0.11.5-5

1 Like

Added accessibility, firefox, speech-dispatcher

Are you using Fedora or Flathub Flatpak apps?

This may just need a sandbox permission change, or also some change in the underlying system.

It may also rely on native messaging, which needs to be solved by a portal. See the issue on that here

A “dirty” workaround to avoid needing native messaging is just running the binary from the browser sandbox. That way they can communicate how they like.

This could totally be done by firefox, as if this needs native messaging, that issue occurs on all Linux distros, and Firefox Flatpak is officially supported.

We should suggest that on Firefoxes Bugzilla, or if someone knows where their flatpak build is, maybe they can include the speech-dispatcher as a runtime or just inside the app.

Or this may be a different issue, explained here

If you’re using Flatpak or Snap, or other sandboxed environments, it won’t be able to spawn speech-dispatcher and you would either need to enable socket activation (it seems currently only Ubuntu ships speech-dispatcher with socket activation enabled) or keep speech-dispatcher running manually yourself.

So there may be a change needed for Fedoras speech-dispatcher

2 Likes

It actually works when manually starting speech-dispatcher daemon with a timeout.
speech-dispatcher -d -t 8000

  -t, --timeout         Set time in seconds for the server to wait before it
                        shuts down, if it has no clients connected. Setting to
                        0 disables such shutdown

Running Flathub’s version.

3 Likes

I have this issue with the default Firefox that comes with Silverblue, which isn’t the Flatpak version…

You can follow the issue here. The tl;dr is that this isn’t possible in any stable release of speechd currently, the distros that ship a working version are shipping an RC version. The current workaround really is running the command mentioned above.

1 Like

So would speech-dispatcher -d -t 0 also work? This sounds like a better version

1 Like

Yup, that works better, it’s what I use at least.

1 Like

Based on this thread, I managed to make an interim workaround until Fedora updates its speech-dispatcher package, which should make sure speech-dispatcher runs when you log int and restarts if it needs to:

First, create the user service unit:

mkdir -p ~/.config/systemd/user
echo "[Unit]
Description=Speech Dispatcher

[Service]
ExecStart=/usr/bin/speech-dispatcher -t 0
Restart=on-failure

[Install]
WantedBy=default.target" > ~/.config/systemd/user/speech-dispatcher.service

Then reload systemctl and enable + start the service:

systemctl --user daemon-reload
systemctl --user enable --now speech-dispatcher.service

…And you’ll have to restart Firefox after enabling the service.

If you ran speech-dispatcher manually (as mentioned above), you’ll also want to killall -9 speech-dispatcher before starting the service (you can do systemctl --user restart speech-dispatcher after that).

I also used the Pied flatpak (which isn’t on Flathub, but is on its GitHub page) to add in a decent sounding voice:

(You have to restart Firefox after adding in the voice. The voice I used was “Libritts R”. It downloads a binary of piper into its flatpak config dir @ ~/.var/app/com.mikeasoft.pied/data/pied/ and modifies your speech dispatcher config @ ~/.config/speech-dispatcher/ — if you have an issue with starting speech-dispatcher for whatever reason, those are the places to look.)

3 Likes

Great guide, I’m personally not experienced enough with creating systemd services to do that, so I was having to remember to manually do that on every reboot, that makes things a lot easier until we have a stable release of speechd where things can work out of the box!