Can't connect speech-dispatcher deamon

Hello, I have a problem with a container that does speech synthesis (text to speech)
When I launch my application, I have an error with the speech dispatcher

Connection to speech-dispatcher failed

I tried to install the package

apt install speech-dispatcher

but it’s the same. When I start the daemon

root@613e09423058:/app# speech-dispatcher
[Tue Sep 19 08:08:58 2023: 945319] speechd: Speech Dispatcher 0.10.2 starting

and I restart my app I have the same error

Connection to speech-dispatcher failed

After some research it’s not a problem with the application, but rather with the speechd daemon

root@d75572a5f3d1:/# spd-say 'hello'
Failed to connect to Speech Dispatcher:
Error: Can't connect to unix socket /root/.cache/speech-dispatcher/speechd.sock: No such file or directory. Autospawn: Autospawn failed. Speech Dispatcher refused to start with error code, stating this as a reason:

Here the different logs:

root@a590016e0d58:/app# cat $HOME/.cache/speech-dispatcher/log/speech-dispatcher.log
[Tue Sep 19 09:57:35 2023 : 870356] speechd:   Speech Dispatcher Logging to file /root/.cache/speech-dispatcher/log//speech-dispatcher.log
[Tue Sep 19 09:57:35 2023 : 870713] speechd:  Configuration has been read from "/etc/speech-dispatcher/speechd.conf"
[Tue Sep 19 09:57:35 2023 : 891917] speechd:  Initializing output module dummy with binary /usr/lib/speech-dispatcher-modules/sd_dummy and configuration /etc/speech-dispatcher/modules/dummy.conf
[Tue Sep 19 09:57:35 2023 : 891969] speechd:   Output module is logging to file /root/.cache/speech-dispatcher/log//dummy.log
[Tue Sep 19 09:57:35 2023 : 892629] speechd:  Module dummy loaded.
[Tue Sep 19 09:57:35 2023 : 897279] speechd:  Module dummy started successfully with message: 
---------------
Everything ok so far.
---------------

[Tue Sep 19 09:57:35 2023 : 911197] speechd:  Error: Module reported error in request from speechd (code 3xx): 300-Opening sound device failed. Reason: Couldn't open pulse plugin. 
300 UNKNOWN ERROR
.
[Tue Sep 19 09:57:35 2023 : 911235] speechd: ERROR: Can't initialize audio in output module, see reason above.
[Tue Sep 19 09:57:35 2023 : 911424] speechd:  Initializing output module espeak-ng with binary /usr/lib/speech-dispatcher-modules/sd_espeak-ng and configuration /etc/speech-dispatcher/modules/espeak-ng.conf
[Tue Sep 19 09:57:35 2023 : 911455] speechd:   Output module is logging to file /root/.cache/speech-dispatcher/log//espeak-ng.log
[Tue Sep 19 09:57:35 2023 : 912132] speechd:  Module espeak-ng loaded.
[Tue Sep 19 09:57:35 2023 : 969833] speechd:  Module espeak-ng started successfully with message: 
---------------
Espeak-ng: Initialized successfully.
---------------

[Tue Sep 19 09:57:35 2023 : 972201] speechd:  Error: Module reported error in request from speechd (code 3xx): 300-Opening sound device failed. Reason: Couldn't open pulse plugin. 
300 UNKNOWN ERROR
.
[Tue Sep 19 09:57:35 2023 : 972236] speechd: ERROR: Can't initialize audio in output module, see reason above.
[Tue Sep 19 09:57:35 2023 : 972347] speechd:   Speech Dispatcher Logging to file /root/.cache/speech-dispatcher/log//speech-dispatcher.log
[Tue Sep 19 09:57:35 2023 : 972395] speechd: Error [speechd.c:683]:No speech output modules were loaded - aborting...
[Tue Sep 19 09:57:35 2023 : 978714] speechd:   Speech Dispatcher Logging to file /root/.cache/speech-dispatcher/log//speech-dispatcher.log
[Tue Sep 19 09:57:35 2023 : 979043] speechd:  Configuration has been read from "/etc/speech-dispatcher/speechd.conf"
[Tue Sep 19 09:57:35 2023 : 996753] speechd:  Initializing output module dummy with binary /usr/lib/speech-dispatcher-modules/sd_dummy and configuration /etc/speech-dispatcher/modules/dummy.conf
[Tue Sep 19 09:57:35 2023 : 996803] speechd:   Output module is logging to file /root/.cache/speech-dispatcher/log//dummy.log
[Tue Sep 19 09:57:35 2023 : 997380] speechd:  Module dummy loaded.
[Tue Sep 19 09:57:35 2023 : 2038] speechd:  Module dummy started successfully with message: 
---------------
Everything ok so far.
---------------

[Tue Sep 19 09:57:36 2023 : 12942] speechd:  Error: Module reported error in request from speechd (code 3xx): 300-Opening sound device failed. Reason: Couldn't open pulse plugin. 
300 UNKNOWN ERROR
.
[Tue Sep 19 09:57:36 2023 : 12979] speechd: ERROR: Can't initialize audio in output module, see reason above.
[Tue Sep 19 09:57:36 2023 : 13172] speechd:  Initializing output module espeak-ng with binary /usr/lib/speech-dispatcher-modules/sd_espeak-ng and configuration /etc/speech-dispatcher/modules/espeak-ng.conf
[Tue Sep 19 09:57:36 2023 : 13203] speechd:   Output module is logging to file /root/.cache/speech-dispatcher/log//espeak-ng.log
[Tue Sep 19 09:57:36 2023 : 13858] speechd:  Module espeak-ng loaded.
[Tue Sep 19 09:57:36 2023 : 69298] speechd:  Module espeak-ng started successfully with message: 
---------------
Espeak-ng: Initialized successfully.
---------------

[Tue Sep 19 09:57:36 2023 : 71587] speechd:  Error: Module reported error in request from speechd (code 3xx): 300-Opening sound device failed. Reason: Couldn't open pulse plugin. 
300 UNKNOWN ERROR
.
[Tue Sep 19 09:57:36 2023 : 71642] speechd: ERROR: Can't initialize audio in output module, see reason above.
[Tue Sep 19 09:57:36 2023 : 71758] speechd:   Speech Dispatcher Logging to file /root/.cache/speech-dispatcher/log//speech-dispatcher.log
[Tue Sep 19 09:57:36 2023 : 71814] speechd: Error [speechd.c:683]:No speech output modules were loaded - aborting...
[Tue Sep 19 09:57:49 2023 : 443789] speechd:   Speech Dispatcher Logging to file /root/.cache/speech-dispatcher/log//speech-dispatcher.log
[Tue Sep 19 09:57:49 2023 : 444531] speechd:  Configuration has been read from "/etc/speech-dispatcher/speechd.conf"
[Tue Sep 19 09:57:49 2023 : 483401] speechd:  Initializing output module dummy with binary /usr/lib/speech-dispatcher-modules/sd_dummy and configuration /etc/speech-dispatcher/modules/dummy.conf
[Tue Sep 19 09:57:49 2023 : 483501] speechd:   Output module is logging to file /root/.cache/speech-dispatcher/log//dummy.log
[Tue Sep 19 09:57:49 2023 : 484583] speechd:  Module dummy loaded.
[Tue Sep 19 09:57:49 2023 : 493591] speechd:  Module dummy started successfully with message: 
---------------
Everything ok so far.
---------------

[Tue Sep 19 09:57:49 2023 : 513811] speechd:  Error: Module reported error in request from speechd (code 3xx): 300-Opening sound device failed. Reason: Couldn't open pulse plugin. 
300 UNKNOWN ERROR
.
[Tue Sep 19 09:57:49 2023 : 513874] speechd: ERROR: Can't initialize audio in output module, see reason above.
[Tue Sep 19 09:57:49 2023 : 514279] speechd:  Initializing output module espeak-ng with binary /usr/lib/speech-dispatcher-modules/sd_espeak-ng and configuration /etc/speech-dispatcher/modules/espeak-ng.conf
[Tue Sep 19 09:57:49 2023 : 514340] speechd:   Output module is logging to file /root/.cache/speech-dispatcher/log//espeak-ng.log
[Tue Sep 19 09:57:49 2023 : 515184] speechd:  Module espeak-ng loaded.
[Tue Sep 19 09:57:49 2023 : 606753] speechd:  Module espeak-ng started successfully with message: 
---------------
Espeak-ng: Initialized successfully.
---------------

[Tue Sep 19 09:57:49 2023 : 608928] speechd:  Error: Module reported error in request from speechd (code 3xx): 300-Opening sound device failed. Reason: Couldn't open pulse plugin. 
300 UNKNOWN ERROR
.
[Tue Sep 19 09:57:49 2023 : 608961] speechd: ERROR: Can't initialize audio in output module, see reason above.
[Tue Sep 19 09:57:49 2023 : 609071] speechd:   Speech Dispatcher Logging to file /root/.cache/speech-dispatcher/log//speech-dispatcher.log
[Tue Sep 19 09:57:49 2023 : 609117] speechd: Error [speechd.c:683]:No speech output modules were loaded - aborting...

I also tried to use this image:

https://hub.docker.com/r/mavlink/qgc-build-linux/dockerfile/ 

but I got the same error

Have any ideas ?

What is the speed-dispatcher? Is it a piece of software? Does it run inside the container? Does it need access to hardware on the host?

Speech Dispatcher is a device independent layer for speech synthesis that provides a common easy to use interface for both client applications (programs that want to speak) and for software synthesizers (programs actually able to convert text to speech)

How do you start speech-dispatcher and then your app? In two separate shells? Running speech-dispatcher will probably just start the server, but quit when you stop it, not continue in background.

If it’s a service/daemon running inside the container, check its status

systemctl status speech-dispatcher
systemctl start speech-dispatcher