Closed Bug 1729750 Opened 3 years ago Closed 1 year ago

Speech synthesis doesn't work in the snap

Categories

(Firefox Build System :: Third Party Packaging, defect, P3)

Firefox 92
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: olivier, Assigned: gerard-majax)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0

Steps to reproduce:

Using the firefox snap, open the devtools console, and enter:

speechSynthesis.speak(new SpeechSynthesisUtterance("Testing 1 2 3"));

Actual results:

Nothing (no text is being spoken).

Expected results:

speech-dispatcher should be speaking "Testing 1 2 3".

This is a snap-specific issue, speech synthesis works well with an unconfined build of firefox. More details at https://forum.snapcraft.io/t/firefox-snap-speech-dispatcher/6165.

Blocks: snap

The Bugbug bot thinks this bug should belong to the 'Core::Web Speech' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Web Speech
Product: Firefox → Core

original poster notes that this is a snap-specific issue not a speech issue

Component: Web Speech → Third Party Packaging
Product: Core → Firefox Build System

The severity field is not set for this bug.
:gerard-majax, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(lissyx+mozillians)
Severity: -- → S3
Flags: needinfo?(lissyx+mozillians)

I was not even able to get speech synthesis to work in non snap firefox either :)

I can confirm it doesn't work for me, neither in the snap nor in the upstream tarball.

For the snap, this thread is relevant.

And a similar issue affecting the chromium snap.

Depends on: 1666703

After bug 1666703 is fixed, there are still a few roadblocks:

  • we need to add libspeechd2 as a stage-packages component in the firefox snap
  • we need to prime usr/lib/*/libspeechd.so.*

That is still not enough. By default, communication is done over a socket $XDG_RUNTIME_DIR/speech-dispatcher/speechd.sock, granting this would need some snapd interface change.

Experimenting further by forcing SPEECHD_ADDRESS=inet_socket (as well as in the configuration file /etc/speech-dispatcher/speechd.conf, one still cannot get speechSynthesis.getVoices() to return more than an empty array. It looks like libspeechd2 somehow handles some auto spawning of the daemon, and I assume this is getting blocked by the Snap-level sandboxing.

This can be bypassed by issuing spd-say -L aside of a running Firefox, and once you have a process spawn quickly isssuing a speechSynthesis.getVoices() to connect to it. Once that is done, Speech Synthesis can work.

Assignee: nobody → lissyx+mozillians
Depends on: 1787245

Auto spawning seems to simply require the executable to be within the Snap. Ubuntu people suggested we rather rely on socket activation as reported on https://github.com/brailcom/speechd/issues/448. That, in combination with bug 1787245 should be enough.

Depends on: 1787418
Priority: -- → P3

According to upstream, some of the problems with socket activation are now fixed. Let's give a new try to this feature.

Nathan or Amin, looks like there has not yet been a release including https://github.com/brailcom/speechd/commit/e7e188f4f118f59f0daa3d53ceece5b3aefcf0d1. Also, we would need this release to be available in core22 and core20 ?

Flags: needinfo?(nathan.teodosio)
Flags: needinfo?(bandali)

According to upstream, some of the problems with socket activation are now fixed. Let's give a new try to this feature.

Alexander, even with e7e188 in, I couldn't get the socket activation to actually work[1].

[1] https://github.com/brailcom/speechd/issues/809

Flags: needinfo?(nathan.teodosio)

Well I was told that it was fixed and pointed to the previous link

Unfortunately I don't have any more information/context around this than what Nathan already provided.

Flags: needinfo?(bandali)

For your information, if trying this in a snap, make sure to supply a correct XDG_RUNTIME_DIR as that seems to be modified by snapcraft or snapd.

Namely, in a snap run --shell {snap-name-with-spd}, this fails:

$ spd-say bye
Failed to connect to Speech Dispatcher:
Error: Can't connect to unix socket /run/user/1000/snap.geheim/speech-dispatcher/speechd.sock: No such file or directory. Autospawn: Autospawn failed. Spawn error 8: Failed to execute child process “/usr/bin/speech-dispatcher” (No such file or directory)

but this works:

$ XDG_RUNTIME_DIR=/run/user/1000 spd-say bye

So I had a look and I'm a bit lost on the packaging differences and how it interacts with snap to hack that. Do you have some PPA or something else with an uptodate deb of speech-dispatcher to build a snap?

Flags: needinfo?(nathan.teodosio)

I built the patched speech-dispatcher in a PPA[1] and then a snap[2] with spd-say to test

After installing them,

systemctl start --user speech-dispatcher.socket
snap run --shell geheim
$ XDG_RUNTIME_DIR=/run/user/1000 spd-say hi

[1] https://launchpad.net/~nteodosio/+archive/ubuntu/rebuilds/+build/26035882
[2] https://launchpad.net/~nteodosio/+snap/test-speechd/+build/2103550

Flags: needinfo?(nathan.teodosio)

(In reply to Nathan Teodosio :nteodosio from comment #18)

I built the patched speech-dispatcher in a PPA[1] and then a snap[2] with spd-say to test

After installing them,

systemctl start --user speech-dispatcher.socket
snap run --shell geheim
$ XDG_RUNTIME_DIR=/run/user/1000 spd-say hi

[1] https://launchpad.net/~nteodosio/+archive/ubuntu/rebuilds/+build/26035882
[2] https://launchpad.net/~nteodosio/+snap/test-speechd/+build/2103550

Thanks but this is not working for me. I dont see in https://git.launchpad.net/~nteodosio/+git/geheim/tree/snapcraft.yaml where you added your PPA reference.

package-repositories:
  - type: apt
    ppa: nteodosio/rebuilds

When I do I hit this error E: The repository 'http://ppa.launchpad.net/nteodosio/rebuilds/ubuntu focal Release' does not have a Release file. which makes sense since the rebuilds PPA targets mantic serie.

Flags: needinfo?(nathan.teodosio)

(In reply to Alexandre LISSY :gerard-majax from comment #19)

(In reply to Nathan Teodosio :nteodosio from comment #18)

I built the patched speech-dispatcher in a PPA[1] and then a snap[2] with spd-say to test

After installing them,

systemctl start --user speech-dispatcher.socket
snap run --shell geheim
$ XDG_RUNTIME_DIR=/run/user/1000 spd-say hi

[1] https://launchpad.net/~nteodosio/+archive/ubuntu/rebuilds/+build/26035882
[2] https://launchpad.net/~nteodosio/+snap/test-speechd/+build/2103550

Thanks but this is not working for me. I dont see in https://git.launchpad.net/~nteodosio/+git/geheim/tree/snapcraft.yaml where you added your PPA reference.

package-repositories:
  - type: apt
    ppa: nteodosio/rebuilds

When I do I hit this error E: The repository 'http://ppa.launchpad.net/nteodosio/rebuilds/ubuntu focal Release' does not have a Release file. which makes sense since the rebuilds PPA targets mantic serie.

When you say "it's not working", do you mean that the recipe I proposed is not working, or that you did not attempt it as proposed since you couldn't find the PPA reference in the snapcraft.yaml of the snap?

The PPA doesn't need to be in the snap, only in the host, as in the latter is the socket and the service to be activated via that socket.

Flags: needinfo?(nathan.teodosio)

I say it's not working because I was assuming I need to use the PPA within the snap build itself, and as stated there's only a mantic release. I will probably have to rebuild from your ppa anyway because my test VM is running 22.04.

dont we risk having different versions of speech-dispatcher between host and snap and potential weird bugs? And when you say host you do refer to the one where we install the snap, not the host used for building, right?

dont we risk having different versions of speech-dispatcher between host and snap and potential weird bugs?

Since the patch would have to be backported to Jammy first so that Firefox could pick it up (I assume we wouldn't want it's snapcraft.yaml to pick up stuff from a PPA), I thought that a positive result with that proposed test case would be OK, but you do have a fair point.

And when you say host you do refer to the one where we install the snap, not the host used for building, right?

Yes, sorry for the lack of clarity there.

So this will require 0.11.4-2ubuntu1 package (currently in mantic-proposed, I did rebuild myself for jammy) to be backported, but I am happy to say it seems to work. Requires a reboot for the systemd socket activation to be active by default, otherwise user needs to systemctl start --user speech-dispatcher.socket as mentionned earlier.

Attached file GitHub Pull Request
See Also: → 1638150

SRU is under review, PR was merged, we can close this. Reopen if there's a problem and the SRU does not make it ?

Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: