@onereach/step-voice 7.0.9-processttschunk.25 → 7.0.9-processttschunk.26
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 +23 -0
- package/dst/Start TTS Chunks Processing.js +15 -0
- package/dst/voice.d.ts +2 -0
- package/package.json +1 -1
package/dst/Process TTS Chunk.js
CHANGED
|
@@ -22,6 +22,29 @@ class ProcessTtsChunk extends voice_1.default {
|
|
|
22
22
|
});
|
|
23
23
|
this.triggers.otherwise(async () => {
|
|
24
24
|
await this.sendCommands({ ...call, type: 'tts-chunk' }, [command]);
|
|
25
|
+
if (textChunk) {
|
|
26
|
+
call.ttsTranscriptBuffer = (call.ttsTranscriptBuffer ?? '') + textChunk;
|
|
27
|
+
}
|
|
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) {
|
|
31
|
+
const message = (call.ttsTranscriptBuffer ?? '').trim();
|
|
32
|
+
call.ttsTranscriptBuffer = '';
|
|
33
|
+
if (message) {
|
|
34
|
+
await this.transcript(call, {
|
|
35
|
+
action: 'Call Prompt',
|
|
36
|
+
sections: [{ text: message }],
|
|
37
|
+
reportingSettingsKey: 'transcript',
|
|
38
|
+
actionFromBot: true
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
await this.updateData();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
await this.updateData();
|
|
47
|
+
}
|
|
25
48
|
this.exitStep('next');
|
|
26
49
|
});
|
|
27
50
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
4
5
|
const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
5
6
|
class StartTTSChunksProcessing extends voice_1.default {
|
|
6
7
|
async runStep() {
|
|
@@ -61,6 +62,20 @@ class StartTTSChunksProcessing extends voice_1.default {
|
|
|
61
62
|
const params = event.params;
|
|
62
63
|
const exitData = this.exitChoiceData('voice', params);
|
|
63
64
|
this.log.info('exitData', exitData);
|
|
65
|
+
const phrases = params.phrases ?? [];
|
|
66
|
+
if (!lodash_1.default.isEmpty(phrases)) {
|
|
67
|
+
const voiceProcessResult = lodash_1.default.chain(phrases)
|
|
68
|
+
.map((p) => p.lexical)
|
|
69
|
+
.join(' | ')
|
|
70
|
+
.value();
|
|
71
|
+
await this.transcript(call, {
|
|
72
|
+
sections: [{ text: phrases[0].text }],
|
|
73
|
+
voiceProcessResult,
|
|
74
|
+
reportingSettingsKey: 'transcriptResponse',
|
|
75
|
+
action: 'Call Recognition',
|
|
76
|
+
actionFromBot: false
|
|
77
|
+
});
|
|
78
|
+
}
|
|
64
79
|
return this.exitStep(event.params.type, exitData, false);
|
|
65
80
|
}
|
|
66
81
|
case 'hangup': {
|
package/dst/voice.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface IVoiceCall extends IConversationData {
|
|
|
18
18
|
endUserNumber: string;
|
|
19
19
|
botNumber: string;
|
|
20
20
|
lastTranscriptId: string;
|
|
21
|
+
/** Accumulates streamed TTS text chunks between flushes to build a single bot transcript. */
|
|
22
|
+
ttsTranscriptBuffer?: string;
|
|
21
23
|
type: string;
|
|
22
24
|
callback: ICallback;
|
|
23
25
|
global?: TODO;
|