feat pause resume transcribe (#438)

* feat pause resume transcribe

* wip

* fix jslint

* update fsmrf
This commit is contained in:
Hoan Luu Huu
2023-08-31 09:43:50 +07:00
committed by GitHub
parent c10c561ba1
commit 2935574440
5 changed files with 65 additions and 11 deletions

View File

@@ -1075,6 +1075,24 @@ ${credential.label ? `, label: ${credential.label}` : ''} is chosen`);
listenTask.updateListen(opts.listen_status);
}
/**
* perform live call control -- change Transcribe status
* @param {object} opts
* @param {string} opts.transcribe_status - 'pause' or 'resume'
*/
async _lccTranscribeStatus(opts) {
const task = this.currentTask;
if (!task || ![TaskName.Dial, TaskName.Transcribe].includes(task.name)) {
return this.logger.info(`CallSession:_lccTranscribeStatus - invalid transcribe_status in task ${task.name}`);
}
const transcribeTask = task.name === TaskName.Transcribe ? task : task.transcribeTask;
if (!transcribeTask) {
return this.logger
.info('CallSession:_lccTranscribeStatus - invalid transcribe_status: Dial does not have a Transcribe');
}
transcribeTask.updateTranscribe(opts.transcribe_status);
}
async _lccMuteStatus(callSid, mute) {
// this whole thing requires us to be in a Dial or Conference verb
const task = this.currentTask;
@@ -1193,6 +1211,9 @@ ${credential.label ? `, label: ${credential.label}` : ''} is chosen`);
if (opts.listen_status) {
await this._lccListenStatus(opts);
}
if (opts.transcribe_status) {
await this._lccTranscribeStatus(opts);
}
else if (opts.mute_status) {
await this._lccMuteStatus(callSid, opts.mute_status === 'mute');
}
@@ -1369,6 +1390,10 @@ ${credential.label ? `, label: ${credential.label}` : ''} is chosen`);
this._lccListenStatus(data);
break;
case 'transcribe:status':
this._lccTranscribeStatus(data);
break;
case 'whisper':
this._lccWhisper(data, call_sid);
break;