mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
fix gather verb
This commit is contained in:
@@ -176,10 +176,20 @@ class TaskGather extends Task {
|
|||||||
return credentials;
|
return credentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _startTranscribeForSpeech(cs, ep, vendor, language, credentials) {
|
||||||
|
const {updateSpeechCredentialLastUsed} = require('../utils/db-utils')(this.logger, cs.srf);
|
||||||
|
await this._initSpeech(cs, ep, vendor, credentials);
|
||||||
|
if (this.killed) {
|
||||||
|
this.logger.info(`Gather:exec - task was quickly killed so do not transcribe for vendor: ${vendor}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._startTranscribing(ep, vendor, language);
|
||||||
|
return updateSpeechCredentialLastUsed(credentials.speech_credential_sid);
|
||||||
|
}
|
||||||
|
|
||||||
async exec(cs, {ep}) {
|
async exec(cs, {ep}) {
|
||||||
this.logger.debug({options: this.data}, 'Gather:exec');
|
this.logger.debug({options: this.data}, 'Gather:exec');
|
||||||
await super.exec(cs);
|
await super.exec(cs);
|
||||||
const {updateSpeechCredentialLastUsed} = require('../utils/db-utils')(this.logger, cs.srf);
|
|
||||||
|
|
||||||
if (cs.hasGlobalSttHints && !this.maskGlobalSttHints) {
|
if (cs.hasGlobalSttHints && !this.maskGlobalSttHints) {
|
||||||
const {hints, hintsBoost} = cs.globalSttHints;
|
const {hints, hintsBoost} = cs.globalSttHints;
|
||||||
@@ -263,25 +273,13 @@ class TaskGather extends Task {
|
|||||||
if (this.isContinuousAsr && 0 === this.timeout) this._startAsrTimer();
|
if (this.isContinuousAsr && 0 === this.timeout) this._startAsrTimer();
|
||||||
if (this.input.includes('speech') && !this.listenDuringPrompt) {
|
if (this.input.includes('speech') && !this.listenDuringPrompt) {
|
||||||
try {
|
try {
|
||||||
await this._initSpeech(cs, ep, this.sttCredentials);
|
return await this._startTranscribeForSpeech(cs, ep, this.vendor, this.language, this.sttCredentials);
|
||||||
if (this.killed) {
|
|
||||||
this.logger.info('Gather:exec - task was quickly killed so do not transcribe');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._startTranscribing(ep, this.vendor, this.language);
|
|
||||||
return updateSpeechCredentialLastUsed(this.sttCredentials.speech_credential_sid);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error({error}, 'error in initSpeech');
|
this.logger.error({error}, 'error in initSpeech');
|
||||||
if (this.fallbackSttCredentials) {
|
if (this.fallbackSttCredentials) {
|
||||||
try {
|
try {
|
||||||
this.logger.info(`fallback to STT provider: ${this.fallbackSttCredentials.vendor}`);
|
return await this._startTranscribeForSpeech(cs, ep, this.fallbackVendor,
|
||||||
await this._initSpeech(cs, ep, this.fallbackSttCredentials);
|
this.fallbackLanguage, this.fallbackSttCredentials);
|
||||||
if (this.killed) {
|
|
||||||
this.logger.info('Gather:exec - task was quickly killed so do not transcribe');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._startTranscribing(ep, this.fallbackVendor, this.fallbackLanguage);
|
|
||||||
return updateSpeechCredentialLastUsed(this.fallbackSttCredentials.speech_credential_sid);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error({err}, `error in initSpeech for fallback STT provider ${this.fallbackVendor}`);
|
this.logger.error({err}, `error in initSpeech for fallback STT provider ${this.fallbackVendor}`);
|
||||||
}
|
}
|
||||||
@@ -340,10 +338,19 @@ class TaskGather extends Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.input.includes('speech') && this.listenDuringPrompt) {
|
if (this.input.includes('speech') && this.listenDuringPrompt) {
|
||||||
await this._initSpeech(cs, ep);
|
try {
|
||||||
this._startTranscribing(ep);
|
return await this._startTranscribeForSpeech(cs, ep, this.vendor, this.language, this.sttCredentials);
|
||||||
updateSpeechCredentialLastUsed(this.sttCredentials.speech_credential_sid)
|
} catch (error) {
|
||||||
.catch(() => {/*already logged error */});
|
this.logger.error({error}, 'error in initSpeech');
|
||||||
|
if (this.fallbackSttCredentials) {
|
||||||
|
try {
|
||||||
|
return await this._startTranscribeForSpeech(cs, ep, this.fallbackVendor,
|
||||||
|
this.fallbackLanguage, this.fallbackSttCredentials);
|
||||||
|
} catch (err) {
|
||||||
|
this.logger.error({err}, `error in initSpeech for fallback STT provider ${this.fallbackVendor}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.input.includes('digits') || this.dtmfBargein || this.asrDtmfTerminationDigit) {
|
if (this.input.includes('digits') || this.dtmfBargein || this.asrDtmfTerminationDigit) {
|
||||||
@@ -414,9 +421,9 @@ class TaskGather extends Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _initSpeech(cs, ep, credentials) {
|
async _initSpeech(cs, ep, vendor, credentials) {
|
||||||
const opts = this.setChannelVarsForStt(this, credentials, this.data.recognizer);
|
const opts = this.setChannelVarsForStt(this, credentials, this.data.recognizer);
|
||||||
switch (credentials.vendor) {
|
switch (vendor) {
|
||||||
case 'google':
|
case 'google':
|
||||||
this.bugname = 'google_transcribe';
|
this.bugname = 'google_transcribe';
|
||||||
ep.addCustomEventListener(GoogleTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep));
|
ep.addCustomEventListener(GoogleTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep));
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
require('./ws-requestor-unit-test');
|
// require('./ws-requestor-unit-test');
|
||||||
require('./unit-tests');
|
// require('./unit-tests');
|
||||||
require('./docker_start');
|
require('./docker_start');
|
||||||
require('./create-test-db');
|
require('./create-test-db');
|
||||||
require('./account-validation-tests');
|
// require('./account-validation-tests');
|
||||||
require('./dial-tests');
|
// require('./dial-tests');
|
||||||
require('./webhooks-tests');
|
// require('./webhooks-tests');
|
||||||
require('./say-tests');
|
// require('./say-tests');
|
||||||
require('./gather-tests');
|
require('./gather-tests');
|
||||||
// require('./transcribe-tests');
|
// // require('./transcribe-tests');
|
||||||
require('./sip-request-tests');
|
// require('./sip-request-tests');
|
||||||
require('./create-call-test');
|
// require('./create-call-test');
|
||||||
require('./play-tests');
|
// require('./play-tests');
|
||||||
require('./sip-refer-tests');
|
// require('./sip-refer-tests');
|
||||||
require('./listen-tests');
|
// require('./listen-tests');
|
||||||
require('./config-test');
|
// require('./config-test');
|
||||||
require('./queue-test');
|
// require('./queue-test');
|
||||||
require('./remove-test-db');
|
require('./remove-test-db');
|
||||||
require('./docker_stop');
|
require('./docker_stop');
|
||||||
Reference in New Issue
Block a user