godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Make the audio produced by `tts_speak()` routeable to Audio Buses to amplify and/or add effects #10690

Open jruiz94 opened 1 week ago

jruiz94 commented 1 week ago

Describe the project you are working on

I'm planning to make a game where robotic voice is needed for the narration of the game. I'm prerecording some segments so I don't need to use text-to-speech but I'd like the game to be able to "speak" the name the player set up at the beggining, even if it's a different voice

Describe the problem or limitation you are having in your project

The volume of the tts_speak() function is not at the same level of the rest of the in-game audio, typically resulting in lower volume, and I can't adjust it higher than the maximum 100 that the function tts_speak() provides. Also I didn't think of this when I was implementing my game, but having the ability to add some audio effects to it would be a huge plus.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

If the audio can be routeable to audio buses, I can amplify the volume and/or add effects

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Add a parameter to the tts_speak() function so you can specify an AudioBus

void tts_speak(text: String, voice: String, volume: int = 50, pitch: float = 1.0, audio_bus: String, rate: float = 1.0, utterance_id: int = 0, interrupt: bool = false)

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, currently the tts_speak() function doesn't allow routing the audio to a bus, so I'm stuck to the maximum 100 volume.

Is there a reason why this should be core and not an add-on in the asset library?

Addons can't modify the default behaviour of a built-in Godot function AFAIK

jruiz94 commented 1 week ago

I'd like to add that I'm open to try to help implementing this (if it's possible to implement, maybe it's not) however I've never contributed to Godot before so if anyone could give me some tips on where to start (like a contributing guide or something), that'd be great thanks in advance

Calinou commented 1 day ago

This is not technically feasible, as the audio from TTS is output by the operating system itself. Godot has no knowledge of this audio and cannot manipulate it in any way.

On the bright side, this also allows projects that can't output audio (e.g. those using the Dummy audio driver) to make use of TTS.

As a reminder, TTS is meant to be an accessibility feature, not a way to act as a character voiceover. This is why volume control is always left in the hands of the user, and users needing TTS will generally configure it in their system settings. Moreover, the TTS implementation is OS-specific, so the output will sound different on each platform.

jruiz94 commented 16 hours ago

Aaah I see. I kinda suspected it'd be this way but I just wanted to ask anyways to be fully sure.

Thanks again for your time i assume this can be closed and left for future reference if anybody stumbles upon this.

Cheers!