waitForSpeech
Waits until the remote side starts speaking and then falls silent.
Description
vcc.waitForSpeech(thresh?: number, speechStartMs?: number, silenceMs?: number, timeoutMs?: number)
Parameters
thresh
The energy threshold above which an audio frame is considered speech. Default is 200.
speechStartMs
The duration of continuous audio required to detect the start of speech, in milliseconds. Default is 100.
silenceMs
The duration of continuous silence required to detect the end of speech, in milliseconds. Default is 1200.
timeoutMs
The maximum wait time in milliseconds for speech to start, and again for speech to end. Limited to the script execution timeout. Default is 30000.
Return values
an object with the following properties (times in milliseconds):
- result:
"ok"if speech was detected and ended;"no_speech"if speech did not start withintimeoutMs;"no_silence"if speech did not end withintimeoutMs; or"hangup"if the call ended - leadMs: from the call of
waitForSpeechto the start of speech - speechMs: the length of the speech, until the timeout at
"no_silence" - endOffsetMs: the end of speech from the answer of the call
Example
var res = vcc.waitForSpeech(200, 100, 1200, 30000);
if (res.result === 'ok') {
// Check if prompt length is within expected tolerance (e.g. 8400 ms +/- 15%)
if (res.speechMs >= 7140 && res.speechMs <= 9660) {
vcc.sendDTMF('1', 300);
} else {
vcc.setVariable('error_reason', 'Unexpected prompt length: ' + res.speechMs + ' ms');
}
} else if (res.result === 'hangup') {
return false;
}
Comments
Can’t find what you need? Use the comment section below to connect with others, get answers from our experts, or share your ideas with us.
There are no comments yet.