@onereach/step-voice 7.0.9-processttschunk.21 → 7.0.9-processttschunk.23
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.
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import VoiceStep, { TODO, VoiceEvent } from './voice';
|
|
2
2
|
interface INPUT {
|
|
3
|
-
/** Required when `chunksStreamingEnabled` is true (ElevenLabs stream). */
|
|
4
3
|
voiceId?: string;
|
|
5
4
|
infiniteProcessing: boolean;
|
|
6
5
|
asr: TODO;
|
|
7
6
|
endpointing: number;
|
|
8
|
-
/** Required when `chunksStreamingEnabled` is true; may be a getter function. */
|
|
9
7
|
voiceSettings?: any;
|
|
10
|
-
/** Required when `chunksStreamingEnabled` is true; may be a getter function. */
|
|
11
8
|
queryParams?: any;
|
|
12
9
|
minConfidence: number;
|
|
13
|
-
/** `true` → ElevenLabs stream (`playbackMode: 'chunks'`). `false` → synthesize + playback per phrase (`phrases`). */
|
|
14
10
|
chunksStreamingEnabled: boolean;
|
|
15
|
-
/** Used when `chunksStreamingEnabled` is false — must expose `getSettings(call.tts)` (or equivalent) for `phraseTtsSettings`. */
|
|
16
11
|
tts?: TODO;
|
|
12
|
+
postPlaybackSilenceMs?: number;
|
|
17
13
|
confirmationConfidence?: number;
|
|
18
14
|
}
|
|
19
15
|
interface EVENT extends VoiceEvent {
|
|
@@ -5,7 +5,7 @@ const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
|
5
5
|
class StartTTSChunksProcessing extends voice_1.default {
|
|
6
6
|
async runStep() {
|
|
7
7
|
const call = await this.fetchData();
|
|
8
|
-
const { voiceId, asr, endpointing, minConfidence, confirmationConfidence, voiceSettings: getSettings, queryParams: getParams, chunksStreamingEnabled, tts } = this.data;
|
|
8
|
+
const { voiceId, asr, endpointing, minConfidence, confirmationConfidence, voiceSettings: getSettings, queryParams: getParams, chunksStreamingEnabled, tts, postPlaybackSilenceMs } = this.data;
|
|
9
9
|
const grammar = {
|
|
10
10
|
id: this.currentStepId,
|
|
11
11
|
asr: {
|
|
@@ -36,7 +36,8 @@ class StartTTSChunksProcessing extends voice_1.default {
|
|
|
36
36
|
params = {
|
|
37
37
|
...base,
|
|
38
38
|
playbackMode: 'phrases',
|
|
39
|
-
phraseTtsSettings: tts.getSettings(call.tts)
|
|
39
|
+
phraseTtsSettings: tts.getSettings(call.tts),
|
|
40
|
+
...(postPlaybackSilenceMs !== undefined ? { postPlaybackSilenceMs } : {})
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
43
|
const command = {
|
|
@@ -44,13 +45,9 @@ class StartTTSChunksProcessing extends voice_1.default {
|
|
|
44
45
|
params
|
|
45
46
|
};
|
|
46
47
|
this.log.debug('StartTTSChunksProcessing command', { command });
|
|
47
|
-
this.triggers.local(`
|
|
48
|
-
this.log.info('Received event from voicer', event);
|
|
48
|
+
this.triggers.local(`otel/voice/${call.id}`, async (event) => {
|
|
49
|
+
this.log.info('Received OTel event from voicer', event.params);
|
|
49
50
|
switch (event.params.type) {
|
|
50
|
-
case 'tts-chunks-playback-done': {
|
|
51
|
-
this.log.info('tts-chunks-playback-done', event.params);
|
|
52
|
-
return this.exitStep('next', {}, false);
|
|
53
|
-
}
|
|
54
51
|
case 'tts-audio/started':
|
|
55
52
|
case 'tts-audio/finished':
|
|
56
53
|
case 'tts-audio/interrupted':
|
|
@@ -60,6 +57,15 @@ class StartTTSChunksProcessing extends voice_1.default {
|
|
|
60
57
|
this.log.warn('Received asr/tts status event', event.params);
|
|
61
58
|
return;
|
|
62
59
|
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
this.triggers.local(`in/voice/${call.id}`, async (event) => {
|
|
63
|
+
this.log.info('Received event from voicer', event);
|
|
64
|
+
switch (event.params.type) {
|
|
65
|
+
case 'tts-chunks-playback-done': {
|
|
66
|
+
this.log.info('tts-chunks-playback-done', event.params);
|
|
67
|
+
return this.exitStep('next', {}, false);
|
|
68
|
+
}
|
|
63
69
|
case 'timeout': {
|
|
64
70
|
this.log.info('timeout', event.params);
|
|
65
71
|
return this.exitStep(event.params.type, {}, false);
|
package/dst/voice.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export interface HandleInterruptionParams<TParams extends VoiceEvent = VoiceEven
|
|
|
76
76
|
}>;
|
|
77
77
|
reportingSettingsKey?: string;
|
|
78
78
|
}
|
|
79
|
-
export type VoiceEvents<TParams> = IEvent<TParams, WITH_VAR<'in/voice/'>> | IEvent<TParams, WITH_VAR<'in/voice/', '/event'>>;
|
|
79
|
+
export type VoiceEvents<TParams> = IEvent<TParams, WITH_VAR<'in/voice/'>> | IEvent<TParams, WITH_VAR<'in/voice/', '/event'>> | IEvent<TParams, WITH_VAR<'otel/voice/'>>;
|
|
80
80
|
export default class VoiceStep<TIn = unknown, TOut = unknown, TParams extends VoiceEvent = VoiceEvent> extends ConvStep<IVoiceCall, TIn & {
|
|
81
81
|
handleCancel?: boolean;
|
|
82
82
|
}, TOut, VoiceEvents<TParams>> {
|