godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.13k stars 21.19k forks source link

DisplayServer.tts_get_voices() returns empty on Linux with official binaries #67863

Closed jamaggs closed 1 year ago

jamaggs commented 2 years ago

Godot version

4.0.beta3

System information

Linux Xubuntu 22.04.01

Issue description

DisplayServer.tts_get_voices() returns empty. For example, print(DisplayServer.tts_get_voices()) prints "[]".

Speech Dispatcher is installed (spd-say 0.11.1), spd-say -L returns a long list of voices, spd-say "hi" says hi as expected.

Steps to reproduce

print(DisplayServer.tts_get_voices())

Minimal reproduction project

TTSexample.zip

Calinou commented 2 years ago

Speech Dispatcher is installed (spd-say 0.11.1), spd-say -L returns a long list of voices, spd-say "hi" says hi as expected.

If you built the engine from source, did you have speech-dispatcher development libraries installed at the time of building? The build system should print a message stating that it wasn't found otherwise.

jamaggs commented 2 years ago

Hi - thanks very much for the reply. I downloaded the binaries rather than built from source. Many thanks

On Tue, 25 Oct 2022 at 18:39, Hugo Locurcio @.***> wrote:

Speech Dispatcher is installed (spd-say 0.11.1), spd-say -L returns a long list of voices, spd-say "hi" says hi as expected.

If you built the engine from source, did you have speech-dispatcher development libraries installed at the time of building? The build system should print a message stating that it wasn't found otherwise.

— Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/67863#issuecomment-1290917162, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3ZZQSCDV3QZOGS6OH4Z46LWFALOLANCNFSM6AAAAAARNVQVX4 . You are receiving this because you authored the thread.Message ID: @.***>

bruvzg commented 2 years ago

Seems like official betas are built without speechd enabled, it's probably result of missing pkg-config file (maybe wrong dependency is installed, it's usually in libspeechd-dev not in speech-dispatcher).

jamaggs commented 2 years ago

Thanks bruvzg for diagnosing the cause. Hopefully it will get resolved in due course, in the meantime I've just called spd-say using OS.execute as a short-term workaround.

pwab commented 1 year ago

I came here while testing lesleyrs/clipboard-narrator with Godot 4.0 Beta 10. I got the following error on Linux Mint 21 with speech-dispatcher 0.11.1:

W 0:00:00:0769   _ready: TTS is not supported by this display server.
  <C++ Source>   servers/display_server.cpp:269 @ tts_get_voices()
  <Stack Trace>  main.gd:52 @ _ready()

If I understand correctly this problem still exists. I wasn't able to find this issue directly because the error message wasn't documented here. So now at least it should be easier to find information about why tts is sometimes not working on Linux.

bruvzg commented 1 year ago

Relevant issue in the Godot buildroot repo - https://github.com/godotengine/buildroot/issues/7

Adding fontconfig should be as easy as adding it to the config files, but there's no speechd for the buildroot, and it would require making packages for the multiple dependencies which are missing as well.

We actually do not need 99% of the speechd to build Godot, only 3 header files (one in case fontconfig and libudev), so it might be worth including it as the thridparty folder of the Godot main repo instead of using system headers.

nightblade9 commented 1 year ago

For anyone else who finds this: the issue appears to be present in the RC1, but it actually relies on some system libraries.

Knowing nothing about speech generation and how Godot's works, to summarize: Godot on Linux relies on the system to have text-to-speech libraries installed.

In my case, I had to install (via pacman) spd-say, festival, and espeakup before it worked. Running spd-say -L should list something other than a dummy voice. Once that worked, Godot's TTS APIs worked beautifully (DisplayServer.tts_*).

pwab commented 1 year ago

Hey @nightblade9 thanks for these additional tips. Possibly this would be a good addition to the docs. Would you mind creating an issue there?

Calinou commented 1 year ago

There's already an issue for this: https://github.com/godotengine/godot-docs/issues/5823

nightblade9 commented 1 year ago

There's already an issue for this: godotengine/godot-docs#5823

I think this issue is more about contributing to Godot itself or building from source, neither of which apply to my case; I'm just a consumer of Godot who knows little to nothing about TTS.

Hey @nightblade9 thanks for these additional tips. Possibly this would be a good addition to the docs. Would you mind creating an issue there?

Sure, I can do that. I also spoke to @akien-mga about how to get this to work when exporting (TL;DR it isn't trivial for Linux), I think that info should also go somewhere in the docs.

Calinou commented 1 year ago

Since TTS on Linux requires users to install specific libraries, it would be best if Godot could detect missing libraries and show an alert using OS::get_singleton()->alert() the first time the project tries to use text-to-speech. (This needs to be an alert as it must be visible for people not starting Godot from a terminal.)

OS::get_singleton()->alert() is unfortunately always blocking until dismissed (which could be problematic for multiplayer games), so we may have to use a custom alert GUI or implement a non-blocking variant.

nightblade9 commented 1 year ago

For anyone interested, my docs PR is open here: https://github.com/godotengine/godot/pull/73408

Thanks for the suggestion @pwab