mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
add vad
This commit is contained in:
@@ -44,6 +44,10 @@ class TaskGather extends Task {
|
|||||||
this.profanityOption = recognizer.profanityOption || 'raw';
|
this.profanityOption = recognizer.profanityOption || 'raw';
|
||||||
this.requestSnr = recognizer.requestSnr || false;
|
this.requestSnr = recognizer.requestSnr || false;
|
||||||
this.initialSpeechTimeoutMs = recognizer.initialSpeechTimeoutMs || 0;
|
this.initialSpeechTimeoutMs = recognizer.initialSpeechTimeoutMs || 0;
|
||||||
|
|
||||||
|
/* vad: if provided, we dont connect to recognizer until voice activity is detected */
|
||||||
|
const {enable, voiceMs = 0, mode = -1} = recognizer.vad || {};
|
||||||
|
this.vad = {enable, voiceMs, mode};
|
||||||
}
|
}
|
||||||
|
|
||||||
this.digitBuffer = '';
|
this.digitBuffer = '';
|
||||||
@@ -197,7 +201,11 @@ class TaskGather extends Task {
|
|||||||
|
|
||||||
async _initSpeech(cs, ep) {
|
async _initSpeech(cs, ep) {
|
||||||
const opts = {};
|
const opts = {};
|
||||||
|
if (this.vad.enable) {
|
||||||
|
opts.START_RECOGNIZING_ON_VAD = 1;
|
||||||
|
if (this.vad.voiceMs) opts.RECOGNIZER_VAD_VOICE_MS = this.vad.voiceMs;
|
||||||
|
if (this.vad.mode >= 0 && this.vad.mode <= 3) opts.RECOGNIZER_VAD_MODE = this.vad.mode;
|
||||||
|
}
|
||||||
if ('google' === this.vendor) {
|
if ('google' === this.vendor) {
|
||||||
if (this.sttCredentials) opts.GOOGLE_APPLICATION_CREDENTIALS = JSON.stringify(this.sttCredentials.credentials);
|
if (this.sttCredentials) opts.GOOGLE_APPLICATION_CREDENTIALS = JSON.stringify(this.sttCredentials.credentials);
|
||||||
Object.assign(opts, {
|
Object.assign(opts, {
|
||||||
|
|||||||
Reference in New Issue
Block a user