Skip to content

Commit

Permalink
fixed dial transcribe is not able to received final transcribe when c…
Browse files Browse the repository at this point in the history
…lose call.
  • Loading branch information
xquanluu committed Feb 11, 2025
1 parent 55b408e commit 29a4d17
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/utils/place-outdial.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,25 @@ class SingleDialer extends Emitter {
this.logger.info(err, 'place-outdial:_configMsEndpoint - error enable inband DTMF');
}
}

const origDestroy = this.ep.destroy.bind(this.ep);
this.ep.destroy = async() => {
try {
if (this.dialTask.transcribeTask) {
// Wait for final transcription before destroying endpoint
// some vendor may take some time to send the final transcription when closing the connectin
// if there is final transcription but the endpoint is destroyed, the transcription will be lost

// wait for maximum 1 second, if the transcription is not received, destroy the endpoint
this.logger.info('SingleDialer:_configMsEndpoint -' +
' Dial with transcribe task, wait for some time before destroy');
await new Promise((resolve) => setTimeout(resolve, 1000));
}
await origDestroy();
} catch (err) {
this.logger.error(err, 'SingleDialer:_configMsEndpoint - error destroying endpoint');
}
};
}

/**
Expand Down

0 comments on commit 29a4d17

Please sign in to comment.