@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.
@@ -3,6 +3,7 @@ interface INPUT {
3
3
  textChunk: string;
4
4
  isFinal: boolean;
5
5
  flush?: boolean;
6
+ hangupAfterPlayback?: boolean;
6
7
  ttsContext: any;
7
8
  }
8
9
  interface EVENT extends VoiceEvent {
@@ -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`); emit the
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
- const voiceProcessResult = lodash_1.default.chain(phrases)
68
- .map((p) => p.lexical)
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: phrases[0].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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "7.0.9-processttschunk.26",
3
+ "version": "7.0.9-processttschunk.28",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",