mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
changes for updateCall pause/resume listen audio
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const Task = require('./task');
|
||||
const {TaskName, TaskPreconditions, ListenEvents} = require('../utils/constants');
|
||||
const {TaskName, TaskPreconditions, ListenEvents, ListenStatus} = require('../utils/constants');
|
||||
const makeTask = require('./make_task');
|
||||
const moment = require('moment');
|
||||
|
||||
@@ -68,6 +68,23 @@ class TaskListen extends Task {
|
||||
this.notifyTaskDone();
|
||||
}
|
||||
|
||||
updateListen(status) {
|
||||
if (!this.killed && this.ep && this.ep.connected) {
|
||||
this.logger.info(`TaskListen:updateListen status ${status}`);
|
||||
switch (status) {
|
||||
case ListenStatus.Pause:
|
||||
this.ep.forkAudioPause().catch((err) => this.logger.info(err, 'TaskListen: error pausing audio'));
|
||||
break;
|
||||
case ListenStatus.Silence:
|
||||
this.ep.forkAudioPause().catch((err) => this.logger.info(err, 'TaskListen: error pausing audio'));
|
||||
break;
|
||||
case ListenStatus.Resume:
|
||||
this.ep.forkAudioResume().catch((err) => this.logger.info(err, 'TaskListen: error resuming audio'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _playBeep(ep) {
|
||||
await ep.play('tone_stream://L=1;%(500, 0, 1500)')
|
||||
.catch((err) => this.logger.info(err, 'TaskListen:_playBeep Error playing beep'));
|
||||
|
||||
@@ -7,6 +7,7 @@ class TaskSay extends Task {
|
||||
this.preconditions = TaskPreconditions.Endpoint;
|
||||
|
||||
this.text = this.data.text;
|
||||
this.loop = this.data.loop || 1;
|
||||
this.earlyMedia = this.data.earlyMedia === true || (parentTask && parentTask.earlyMedia);
|
||||
if (this.data.synthesizer) {
|
||||
this.voice = this.data.synthesizer.voice;
|
||||
@@ -26,11 +27,14 @@ class TaskSay extends Task {
|
||||
super.exec(cs);
|
||||
this.ep = ep;
|
||||
try {
|
||||
await ep.speak({
|
||||
ttsEngine: 'google_tts',
|
||||
voice: this.voice || this.callSession.speechSynthesisVoice,
|
||||
text: this.text
|
||||
});
|
||||
while (!this.killed && this.loop--) {
|
||||
this.logger.debug(`TaskSay: remaining loops ${this.loop}`);
|
||||
await ep.speak({
|
||||
ttsEngine: 'google_tts',
|
||||
voice: this.voice || this.callSession.speechSynthesisVoice,
|
||||
text: this.text
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
this.logger.info(err, 'TaskSay:exec error');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user