$dialer.setTtsConfig
This method overrides the TTS provider settings of the phone channel used for the current call.
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.
// Google provider settings
$dialer.setTtsConfig({
lang: "tr-TR",
voice: "tr-TR-Wavenet-E",
});
- 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.
The method returns an object with the new provider settings.
You can get the current settings during a call using the $dialer.getTtsConfig
method.
Provider settings
Google
-
lang
- Synthesized speech language.
-
voice
- Speech synthesis voice.
tipSee the complete list of languages and voices for synthesis in the Google documentation. -
- Voice pitch.
Takes an integer or float value from
-20
to20
, where-20
means a 20-halftone decrease from the original tone, and20
means the same increase.
- Voice pitch.
Takes an integer or float value from
-
- Synthesized speech rate.
Takes an integer or float value from
0.25
to4
, where1
is the normal voice speed.
- Synthesized speech rate.
Takes an integer or float value from
-
- Volume increase in dB relative to the normal voice volume.
Takes an integer or float value from
-96
to16
. When set to6
, the volume is approximately twice as high as normal.
- Volume increase in dB relative to the normal voice volume.
Takes an integer or float value from
Yandex
The list of available settings depends on the TTS version.
You can get the current version during a call via $dialer.getTtsConfig
.
If the useV3
parameter is set to true
, then the third version of the Yandex SpeechKit protocol is used.
Select a version in the connection settings.
Do not change the value of the useV3
parameter via $dialer.setTtsConfig
as this can cause TTS errors.
- v1
- v3
lang
- Speech synthesis language.
voice
- Speech synthesis voice.
speed
- Synthesized speech rate.
Takes an integer or float value from
0.1
to3
, where1
is the normal voice speed.
- Synthesized speech rate.
Takes an integer or float value from
emotion
-
Speaker role, which is a characteristic of the voice. For example, the speaker can sound friendlier or whisper.
cautionIf you use a role that is not supported for the current voice, a TTS error will occur.
-
-
lang
- Speech synthesis language.
-
voice
- Speech synthesis voice.
-
speed
- Synthesized speech rate.
Takes an integer or float value from
0.1
to3
, where1
is the normal voice speed.
- Synthesized speech rate.
Takes an integer or float value from
-
volume
- Synthesized speech loudness relative to full scale (LUFS).
Takes an integer or float value from
-145
to0
. The recommended value range is from−20
to−16
LUFS.
- Synthesized speech loudness relative to full scale (LUFS).
Takes an integer or float value from
-
role
-
A characteristic of the voice. For example, the speaker can sound friendlier or whisper.
cautionIf you use a role that is not supported for the current voice, a TTS error will occur.
-
-
useVariables
- If the setting is enabled, speech synthesis is done via Yandex SpeechKit Brand Voice Adaptive, which supports variables.
See the complete list of languages, voices, and roles in the Yandex documentation.
Azure
-
language
- Synthesized speech language.
-
voiceName
- Speech synthesis voice.
tipSee the complete list of languages and voices for synthesis in the Azure documentation. -
sampleRate
- Sample rate.
Aimyvoice
voice
- Speech synthesis voice.
3iTech
model
- Speech synthesis language model.
sampleRate
- Sample rate.
speed
- Synthesized speech rate.
tone
- Voice tone.
ElevenLabs
-
voiceId
-
Voice ID. You can copy it in the ElevenLabs interface.
noteThe ElevenLabs website is not available for Russian IP addresses.
-
-
modelId
- Model for speech synthesis.
-
stability
- Controls voice stability and synthesis variation. At low values the voice sounds emotional, at high values it sounds monotonous. Accepts values from
0
to1
.
- Controls voice stability and synthesis variation. At low values the voice sounds emotional, at high values it sounds monotonous. Accepts values from
-
similarityBoost
- Controls how closely the AI should imitate the original voice. Accepts values from
0
to1
.
- Controls how closely the AI should imitate the original voice. Accepts values from
-
style
- Amplifies the style of the original voice. Accepts values from
0
to1
. Values above0
require more resources and might increase the latency.
- Amplifies the style of the original voice. Accepts values from
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.