mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-19 04:17:44 +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 {TaskName, TaskPreconditions} = require('../utils/constants');
|
||||
const pollySSMLSplit = require('polly-ssml-split');
|
||||
const { SpeechCredentialError } = require('../utils/error');
|
||||
const { SpeechCredentialError, NonFatalTaskError } = require('../utils/error');
|
||||
const { sleepFor } = require('../utils/helpers');
|
||||
const { NON_FANTAL_ERRORS } = require('../utils/constants.json');
|
||||
|
||||
/**
|
||||
* Discard unmatching responses:
|
||||
@@ -402,11 +403,19 @@ class TaskSay extends TtsTask {
|
||||
this._playResolve = resolve;
|
||||
this._playReject = reject;
|
||||
});
|
||||
const r = await ep.play(filename);
|
||||
this.logger.debug({r}, 'Say:exec play result');
|
||||
if (r.playbackSeconds == null && r.playbackMilliseconds == null && r.playbackLastOffsetPos == null) {
|
||||
this._playReject(new Error('Playback failed to start'));
|
||||
try {
|
||||
const r = await ep.play(filename);
|
||||
this.logger.debug({r}, 'Say:exec play result');
|
||||
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 {
|
||||
// wait for playback-stop event received to confirm if the playback is successful
|
||||
await this._playPromise;
|
||||
|
||||
@@ -356,5 +356,8 @@
|
||||
"WS_CLOSE_CODES": {
|
||||
"NormalClosure": 1000,
|
||||
"GoingAway": 1001
|
||||
}
|
||||
},
|
||||
"NON_FANTAL_ERRORS": [
|
||||
"File Not Found"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user