@onereach/step-voice 7.0.9-processttschunk.24 → 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 -14
- package/dst/voice.d.ts +3 -1
- 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() {
|
|
@@ -45,20 +46,6 @@ class StartTTSChunksProcessing extends voice_1.default {
|
|
|
45
46
|
params
|
|
46
47
|
};
|
|
47
48
|
this.log.debug('StartTTSChunksProcessing command', { command });
|
|
48
|
-
// this.triggers.local(`otel/voice/${call.id}`, async (event) => {
|
|
49
|
-
// this.log.info('Received OTel event from voicer', event.params)
|
|
50
|
-
// switch (event.params.type) {
|
|
51
|
-
// case 'tts-audio/started':
|
|
52
|
-
// case 'tts-audio/finished':
|
|
53
|
-
// case 'tts-audio/interrupted':
|
|
54
|
-
// case 'asr-input/started':
|
|
55
|
-
// case 'asr-input/ended':
|
|
56
|
-
// case 'asr-input/processed': {
|
|
57
|
-
// this.log.warn('Received asr/tts status event', event.params)
|
|
58
|
-
// return
|
|
59
|
-
// }
|
|
60
|
-
// }
|
|
61
|
-
// })
|
|
62
49
|
this.triggers.local(`in/voice/${call.id}`, async (event) => {
|
|
63
50
|
this.log.info('Received event from voicer', event);
|
|
64
51
|
switch (event.params.type) {
|
|
@@ -75,6 +62,20 @@ class StartTTSChunksProcessing extends voice_1.default {
|
|
|
75
62
|
const params = event.params;
|
|
76
63
|
const exitData = this.exitChoiceData('voice', params);
|
|
77
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
|
+
}
|
|
78
79
|
return this.exitStep(event.params.type, exitData, false);
|
|
79
80
|
}
|
|
80
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;
|
|
@@ -76,7 +78,7 @@ export interface HandleInterruptionParams<TParams extends VoiceEvent = VoiceEven
|
|
|
76
78
|
}>;
|
|
77
79
|
reportingSettingsKey?: string;
|
|
78
80
|
}
|
|
79
|
-
export type VoiceEvents<TParams> = IEvent<TParams, WITH_VAR<'in/voice/'>> | IEvent<TParams, WITH_VAR<'in/voice/', '/event'
|
|
81
|
+
export type VoiceEvents<TParams> = IEvent<TParams, WITH_VAR<'in/voice/'>> | IEvent<TParams, WITH_VAR<'in/voice/', '/event'>>;
|
|
80
82
|
export default class VoiceStep<TIn = unknown, TOut = unknown, TParams extends VoiceEvent = VoiceEvent> extends ConvStep<IVoiceCall, TIn & {
|
|
81
83
|
handleCancel?: boolean;
|
|
82
84
|
}, TOut, VoiceEvents<TParams>> {
|