Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text to speech draining CPU with Pulse Audio when not in use #77124

Closed
lawnjelly opened this issue May 16, 2023 · 4 comments · Fixed by #77132
Closed

Text to speech draining CPU with Pulse Audio when not in use #77124

lawnjelly opened this issue May 16, 2023 · 4 comments · Fixed by #77132

Comments

@lawnjelly
Copy link
Member

lawnjelly commented May 16, 2023

Godot version

Present in 3.x and master, I've milestoned for 3.6 as I'm investigating in 3.x but same will apply in master.
3.x current (16 may 2023) (567128b), 4.x (last week)

System information

Linux Mint 20.1

Issue description

Note - This issue is related (but not the same) as #55608 . That issue was due to the engine using Pulse Audio, this is due to text to speech (TTS).

System monitor shows that running even the project manager, speech dispatcher is using Pulse Audio which uses significant CPU (11% in my case) even when Godot audio output is switched off (using dummy driver).

By using pactl list clients you can list which apps are causing PulseAudio to use CPU.

This info here regards 3.x, but reports indicate the same problem in 4.x. See #55608 (comment) .

The normal for the engine audio output is:

Client #51
	Driver: protocol-native.c
	Owner Module: 12
	Properties:
		application.name = "Godot Engine Editor"
		native-protocol.peer = "UNIX socket client"
		native-protocol.version = "33"
		application.process.id = "9158"
		application.process.user = "baron"
		application.process.host = "baron-fanless"
		application.process.binary = "Godot_v3.6-beta1_x11.64"
		application.language = "C"
		window.x11.display = ":0"
		application.process.machine_id = ""
		application.process.session_id = "c2"

When text to speech is active you get this:

Client #54
	Driver: protocol-native.c
	Owner Module: 12
	Properties:
		application.name = "speech-dispatcher-espeak-ng"
		native-protocol.peer = "UNIX socket client"
		native-protocol.version = "33"
		application.process.id = "9257"
		application.process.user = "baron"
		application.process.host = "baron-fanless"
		application.process.binary = "sd_espeak-ng"
		application.language = "C"
		window.x11.display = ":0"
		application.process.machine_id = ""
		application.process.session_id = "c2"

Client #55
	Driver: protocol-native.c
	Owner Module: 12
	Properties:
		application.name = "speech-dispatcher-generic"
		native-protocol.peer = "UNIX socket client"
		native-protocol.version = "33"
		application.process.id = "9267"
		application.process.user = "baron"
		application.process.host = "baron-fanless"
		application.process.binary = "sd_generic"
		application.language = "C"
		window.x11.display = ":0"
		application.process.machine_id = ""
		application.process.session_id = "c2"

Client #56
	Driver: protocol-native.c
	Owner Module: 12
	Properties:
		application.name = "speech-dispatcher-dummy"
		native-protocol.peer = "UNIX socket client"
		native-protocol.version = "33"
		application.process.id = "9270"
		application.process.user = "baron"
		application.process.host = "baron-fanless"
		application.process.binary = "sd_dummy"
		application.language = "C"
		window.x11.display = ":0"
		application.process.machine_id = ""
		application.process.session_id = "c2"

This problem may also occur in different form on other platforms, but both my and @wb14123 's reports are on Linux, so can only confirm there so far.

Steps to reproduce

Just run the engine to get the project manager, examine system monitor to see CPU use per process, and run pactl list clients.

What makes this more tricky is that this problem appears to be intermittent. I haven't quite pinned down why it is occurring some runs / builds and not others, will add more info as it becomes apparent.

EDIT: Ah the intermittent nature may be because I get Warning: Speech Dispatcher development libraries not found. Disabling Text-to-Speech support. on local builds, but production builds presumably are compiling with text to speech, and getting the problem.

Minimal reproduction project

N/A

Discussion

The issue appears to be caused because Godot's TTS is always on. It will probably be fixed if we can add a project setting whether to use TTS or not. See:
#55608 (comment)

Presumably the issue is caused by #61316 / #56192 .

@lawnjelly lawnjelly added this to the 3.6 milestone May 16, 2023
@lawnjelly lawnjelly changed the title Text to speech draining CPU with Pulse Audio Text to speech draining CPU with Pulse Audio when not in use May 16, 2023
@lawnjelly
Copy link
Member Author

lawnjelly commented May 16, 2023

@bruvzg are you able to add the project setting to turn TTS off in 3.x and 4.x?

I've just had a look and I could do it, but I'm totally unfamiliar with the TTS so it would likely be quicker for you, and you would likely make a better job of it. Also it might be an idea to have a command line switch at runtime to override the project setting, turning it on or off. 🤔

@bruvzg
Copy link
Member

bruvzg commented May 16, 2023

are you able to add the project setting to turn TTS off in 3.x and 4.x?

Sure, I'll do it.

@lawnjelly
Copy link
Member Author

Reopening as this still needs a 3.x version. I started looking but there are some differences in the Android in 3.x and I'm not familiar with this area so might require @bruvzg to backport.

@akien-mga
Copy link
Member

Fixed by #77352.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants