mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
allow say verb failed as NonFatalTaskError for File Not Found (#1443)
* allow say verb failed as NonFatalTaskError for File Not Found * wip
This commit is contained in:
@@ -2,8 +2,9 @@ const assert = require('assert');
|
|||||||
const TtsTask = require('./tts-task');
|
const TtsTask = require('./tts-task');
|
||||||
const {TaskName, TaskPreconditions} = require('../utils/constants');
|
const {TaskName, TaskPreconditions} = require('../utils/constants');
|
||||||
const pollySSMLSplit = require('polly-ssml-split');
|
const pollySSMLSplit = require('polly-ssml-split');
|
||||||
const { SpeechCredentialError } = require('../utils/error');
|
const { SpeechCredentialError, NonFatalTaskError } = require('../utils/error');
|
||||||
const { sleepFor } = require('../utils/helpers');
|
const { sleepFor } = require('../utils/helpers');
|
||||||
|
const { NON_FANTAL_ERRORS } = require('../utils/constants.json');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discard unmatching responses:
|
* Discard unmatching responses:
|
||||||
@@ -402,11 +403,19 @@ class TaskSay extends TtsTask {
|
|||||||
this._playResolve = resolve;
|
this._playResolve = resolve;
|
||||||
this._playReject = reject;
|
this._playReject = reject;
|
||||||
});
|
});
|
||||||
const r = await ep.play(filename);
|
try {
|
||||||
this.logger.debug({r}, 'Say:exec play result');
|
const r = await ep.play(filename);
|
||||||
if (r.playbackSeconds == null && r.playbackMilliseconds == null && r.playbackLastOffsetPos == null) {
|
this.logger.debug({r}, 'Say:exec play result');
|
||||||
this._playReject(new Error('Playback failed to start'));
|
if (r.playbackSeconds == null && r.playbackMilliseconds == null && r.playbackLastOffsetPos == null) {
|
||||||
|
this._playReject(new Error('Playback failed to start'));
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (NON_FANTAL_ERRORS.includes(err.message)) {
|
||||||
|
throw new NonFatalTaskError(err.message);
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// wait for playback-stop event received to confirm if the playback is successful
|
// wait for playback-stop event received to confirm if the playback is successful
|
||||||
await this._playPromise;
|
await this._playPromise;
|
||||||
|
|||||||
@@ -356,5 +356,8 @@
|
|||||||
"WS_CLOSE_CODES": {
|
"WS_CLOSE_CODES": {
|
||||||
"NormalClosure": 1000,
|
"NormalClosure": 1000,
|
||||||
"GoingAway": 1001
|
"GoingAway": 1001
|
||||||
}
|
},
|
||||||
|
"NON_FANTAL_ERRORS": [
|
||||||
|
"File Not Found"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user