$reactions.ttsWithVariables
The method configures the audio and text template to use for speech synthesis with variables via Yandex SpeechKit Brand Voice Adaptive.
Syntax
The method accepts an object containing the audioTemplate
and textTemplate
properties.
audioTemplate
audioTemplate
describes the audio where the variable part should be inserted. It contains three properties:
audio
— the template audio URL.
textTemplate
describes the audio transcription:template
is the template text, with variable parts replaced with variable names in curly braces.textVariables
is an array of objects describing each variable used. Every object contains two properties:name
is the variable name.value
is the transcription of the audio segment replaced with the variable.
audioVariables
is an array of objects describing the placement of variables in the recording. Every object contains three properties:name
is the variable name.startMs
is the time from the audio start to the beginning of the variable part, in milliseconds.lengthMs
is the length of the variable part playback, in milliseconds.
textTemplate
textTemplate
describes the text to be synthesized by the bot. It contains two properties:
template
is the template text, with variable parts replaced with variable names in curly braces.textVariables
is an array of objects describing the variables to be inserted into the template. Every object contains two properties:name
is the variable name.value
is the text to be synthesized.
audioTemplate
and textTemplate
follows the specification of AudioTemplate
and TextTemplate
as described in the Yandex SpeechKit documentation.How to use
This is an example call to the method from the script:
$reactions.ttsWithVariables({
"audioTemplate": {
"audio": "https://mybucket.s3-ap-southeast-1.amazonaws.com/myfilename.wav",
"textTemplate": {
"template": "You have been approved a loan of {limit} dollars. Would you like to proceed?",
"textVariables": [
{
"name": "limit",
"value": "thirty two thousand"
}
]
},
"audioVariables": [
{
"name": "limit",
"startMs": 1850,
"lengthMs": 1400
}
]
},
"textTemplate": {
"template": "You have been approved a loan of {limit} dollars. Would you like to proceed?",
"textVariables": [
{
"name": "limit",
"value": "sixty seven thousand"
}
]
}
});
The audio file for this example has thirty two thousand mentioned as the loan amount.
audioTemplate
specifies the audio file URL and the variable placement in the recording.
textTemplate
describes the phrase synthesized by the bot in the state where this method is called.
Here, the limit
variable will be replaced with sixty seven thousand.
In a real script, the actual variable values will be different based on the dialog context.