mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
more testing
This commit is contained in:
@@ -11,7 +11,7 @@ class TaskGather extends Task {
|
||||
[
|
||||
'action', 'finishOnKey', 'hints', 'input', 'method', 'numDigits',
|
||||
'partialResultCallback', 'partialResultCallbackMethod', 'profanityFilter',
|
||||
'speechTimeout', 'timeout', 'say'
|
||||
'speechTimeout', 'timeout', 'say', 'play'
|
||||
].forEach((k) => this[k] = this.data[k]);
|
||||
|
||||
this.partialResultCallbackMethod = this.partialResultCallbackMethod || 'POST';
|
||||
@@ -28,6 +28,7 @@ class TaskGather extends Task {
|
||||
this._earlyMedia = this.data.earlyMedia === true;
|
||||
|
||||
if (this.say) this.sayTask = makeTask(this.logger, {say: this.say}, this);
|
||||
if (this.play) this.playTask = makeTask(this.logger, {play: this.play}, this);
|
||||
}
|
||||
|
||||
get name() { return TaskName.Gather; }
|
||||
@@ -48,6 +49,12 @@ class TaskGather extends Task {
|
||||
if (!this.killed) this._startTimer();
|
||||
});
|
||||
}
|
||||
else if (this.playTask) {
|
||||
this.playTask.exec(cs, ep); // kicked off, _not_ waiting for it to complete
|
||||
this.playTask.on('playDone', (err) => {
|
||||
if (!this.killed) this._startTimer();
|
||||
});
|
||||
}
|
||||
else this._startTimer();
|
||||
|
||||
if (this.input.includes('speech')) {
|
||||
@@ -122,7 +129,8 @@ class TaskGather extends Task {
|
||||
}
|
||||
|
||||
_killAudio() {
|
||||
this.sayTask.kill();
|
||||
if (this.sayTask && !this.sayTask.killed) this.sayTask.kill();
|
||||
if (this.playTask && !this.playTask.killed) this.playTask.kill();
|
||||
}
|
||||
|
||||
_onTranscription(ep, evt) {
|
||||
@@ -138,13 +146,13 @@ class TaskGather extends Task {
|
||||
async _resolve(reason, evt) {
|
||||
this.logger.debug(`TaskGather:resolve with reason ${reason}`);
|
||||
|
||||
this._clearTimer();
|
||||
if (reason.startsWith('dtmf')) {
|
||||
this.performAction(this.method, null, {digits: this.digitBuffer});
|
||||
await this.performAction(this.method, null, {digits: this.digitBuffer});
|
||||
}
|
||||
else if (reason.startsWith('speech')) {
|
||||
this.performAction(this.method, null, {speech: evt});
|
||||
await this.performAction(this.method, null, {speech: evt});
|
||||
}
|
||||
this._clearTimer();
|
||||
this.notifyTaskDone();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user