@onereach/step-voice 7.0.9-processttschunk.26 → 7.0.9-processttschunk.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dst/Process TTS Chunk.js
CHANGED
|
@@ -5,7 +5,7 @@ const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
|
5
5
|
class ProcessTtsChunk extends voice_1.default {
|
|
6
6
|
async runStep() {
|
|
7
7
|
const call = await this.fetchData();
|
|
8
|
-
const { textChunk, isFinal, flush, ttsContext: getTtsContext } = this.data;
|
|
8
|
+
const { textChunk, isFinal, flush, hangupAfterPlayback, ttsContext: getTtsContext } = this.data;
|
|
9
9
|
const ttsContext = await getTtsContext.call(this);
|
|
10
10
|
const command = {
|
|
11
11
|
name: 'process-tts-chunk',
|
|
@@ -13,6 +13,7 @@ class ProcessTtsChunk extends voice_1.default {
|
|
|
13
13
|
chunk: textChunk,
|
|
14
14
|
isFinal,
|
|
15
15
|
flush,
|
|
16
|
+
hangupAfterPlayback: Boolean(hangupAfterPlayback),
|
|
16
17
|
ttsContext
|
|
17
18
|
}
|
|
18
19
|
};
|
|
@@ -25,9 +26,9 @@ class ProcessTtsChunk extends voice_1.default {
|
|
|
25
26
|
if (textChunk) {
|
|
26
27
|
call.ttsTranscriptBuffer = (call.ttsTranscriptBuffer ?? '') + textChunk;
|
|
27
28
|
}
|
|
28
|
-
// A chunk series ends on `flush` (or the terminal `isFinal`);
|
|
29
|
-
// accumulated bot speech as a single transcript event and start a new series.
|
|
30
|
-
if (flush || isFinal) {
|
|
29
|
+
// A chunk series ends on `flush` (or the terminal `isFinal` / hangupAfterPlayback);
|
|
30
|
+
// emit the accumulated bot speech as a single transcript event and start a new series.
|
|
31
|
+
if (flush || isFinal || hangupAfterPlayback) {
|
|
31
32
|
const message = (call.ttsTranscriptBuffer ?? '').trim();
|
|
32
33
|
call.ttsTranscriptBuffer = '';
|
|
33
34
|
if (message) {
|
|
@@ -64,13 +64,11 @@ class StartTTSChunksProcessing extends voice_1.default {
|
|
|
64
64
|
this.log.info('exitData', exitData);
|
|
65
65
|
const phrases = params.phrases ?? [];
|
|
66
66
|
if (!lodash_1.default.isEmpty(phrases)) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.join(' | ')
|
|
70
|
-
.value();
|
|
67
|
+
// phrases are ordered by confidence; use the top one only.
|
|
68
|
+
const [bestPhrase] = phrases;
|
|
71
69
|
await this.transcript(call, {
|
|
72
|
-
sections: [{ text:
|
|
73
|
-
voiceProcessResult,
|
|
70
|
+
sections: [{ text: bestPhrase.text }],
|
|
71
|
+
voiceProcessResult: bestPhrase.lexical ?? bestPhrase.text,
|
|
74
72
|
reportingSettingsKey: 'transcriptResponse',
|
|
75
73
|
action: 'Call Recognition',
|
|
76
74
|
actionFromBot: false
|