Skip to main content

$dialer.setTtsConfig

This method overrides the TTS provider settings of the phone channel used for the current call.

tip
The new settings apply only to the current session and don’t affect the global channel settings. They are used until overridden once again or until the call has finished.

Syntax

The method accepts an object with the new TTS settings. It is not necessary to pass all provider settings every time: you only need to specify the ones that should be overridden.

The method returns an object with the new provider settings.

tip
The settings that can be overridden are different for each provider. Refer to the article about $dialer.getTtsConfig to learn which settings there are, and use this method to obtain them in the script.
// Google provider settings
$dialer.setTtsConfig({
lang: "tr-TR",
voice: "tr-TR-Wavenet-E",
});
caution
If you specify object properties not supported by the provider, they will be ignored. If you pass something other than an object (like a string), an error will be raised in the script.

How to use

Some providers, such as Google and Azure, support male as well as female voices for most languages. You can change the bot voice from the script based on some user traits (like their gender or age) or if they want so.

state: SwitchGender
q!: * switch gender *
script:
var provider = $dialer.getAsrProvider(); # Get the current provider name

if (provider === "google") {
var voice = $dialer.getTtsConfig().voice; # Get the current voice
$temp.isMaleVoice = voice.endsWith("B") || voice.endsWith("D"); # Male voices end with B and D

var newVoiceLetter = (isMaleVoice ? ["A", "C"] : ["B", "D"])[$reactions.random(2)];
$dialer.setTtsConfig({ voice: "en-US-Wavenet-" + newVoiceLetter });
} else {
# For other providers, the properties and values to be overridden may be different
}
a: I am now speaking a {{$temp.isMaleVoice ? "female" : "male"}} voice.