@onereach/step-voice 7.0.2-processttschunk.14 → 7.0.2-processttschunk.17

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.
@@ -2,6 +2,8 @@ import VoiceStep, { VoiceEvent } from './voice';
2
2
  interface INPUT {
3
3
  textChunk: string;
4
4
  isFinal: boolean;
5
+ flush: boolean;
6
+ voiceSettings: any;
5
7
  }
6
8
  interface EVENT extends VoiceEvent {
7
9
  exitId?: string;
@@ -5,19 +5,26 @@ 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 } = this.data;
8
+ const { textChunk, isFinal, flush, voiceSettings } = this.data;
9
9
  const command = {
10
10
  name: 'process-tts-chunk',
11
11
  params: {
12
12
  chunk: textChunk,
13
- isFinal
13
+ isFinal,
14
+ flush,
15
+ voiceSettings,
14
16
  }
15
17
  };
18
+ const sensitiveData = {
19
+ muteStep: false,
20
+ muteUser: false,
21
+ muteBot: false,
22
+ };
16
23
  this.triggers.local(`in/voice/${call.id}`, async (event) => {
17
24
  this.log.info('Received event from voicer', event);
18
25
  });
19
26
  this.triggers.otherwise(async () => {
20
- await this.sendCommands({ ...call, type: 'tts-chunk' }, [command]);
27
+ await this.pauseRecording(call, command, sensitiveData);
21
28
  this.exitStep('next');
22
29
  });
23
30
  }
package/dst/voice.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICallback, IPromtpSection, ITypedEvent, IVoiceReporterTranscriptEventArgs } from '@onereach/flow-sdk/dst/types';
1
+ import { ICallback, IVoiceReporterTranscriptEventArgs, IPromtpSection, ITypedEvent } from '@onereach/flow-sdk/dst/types';
2
2
  import ConvStep, { IConversationData } from './step';
3
3
  import BasicError from '@onereach/flow-sdk/dst/errors/base';
4
4
  export type TODO = any;
@@ -30,7 +30,7 @@ export interface IVoiceCall extends IConversationData {
30
30
  user: string;
31
31
  };
32
32
  }
33
- export type EventType = 'hangup' | 'ack' | 'error' | 'cancel' | 'background' | 'avm-detected' | 'recognition' | 'digit' | 'digits' | 'conference-start' | 'conference-end' | 'playback' | 'timeout' | 'record' | 'bridge' | 'bridge/ended' | 'is_flow_ready' | 'call' | 'dtmf-sent' | 'tts-chunks-playback-done';
33
+ export type EventType = 'hangup' | 'ack' | 'error' | 'cancel' | 'background' | 'avm-detected' | 'recognition' | 'digit' | 'digits' | 'conference-start' | 'conference-end' | 'playback' | 'timeout' | 'record' | 'bridge' | 'bridge/ended' | 'is_flow_ready' | 'call' | 'dtmf-sent';
34
34
  export declare class VoiceStepError extends BasicError {
35
35
  }
36
36
  export type VoicerError = Error & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "7.0.2-processttschunk.14",
3
+ "version": "7.0.2-processttschunk.17",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",
@@ -1,14 +0,0 @@
1
- import VoiceStep, { TODO, VoiceEvent } from './voice';
2
- interface INPUT {
3
- voiceId: string;
4
- infiniteProcessing: boolean;
5
- asr: TODO;
6
- endpointing: number | false;
7
- }
8
- interface EVENT extends VoiceEvent {
9
- phrases?: TODO[];
10
- }
11
- export default class StartTTSChunksProcessing extends VoiceStep<INPUT, {}, EVENT> {
12
- runStep(): Promise<void>;
13
- }
14
- export {};
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const voice_1 = tslib_1.__importDefault(require("./voice"));
5
- class StartTTSChunksProcessing extends voice_1.default {
6
- async runStep() {
7
- const call = await this.fetchData();
8
- const { voiceId, infiniteProcessing, asr, endpointing } = this.data;
9
- const grammar = {
10
- id: this.currentStepId,
11
- asr: {
12
- ...asr.getSettings(call.asr),
13
- endpointing
14
- },
15
- };
16
- const command = {
17
- name: 'start-TTS-chunks-processing',
18
- params: {
19
- voiceId,
20
- infiniteProcessing,
21
- grammar
22
- }
23
- };
24
- this.triggers.local(`in/voice/${call.id}`, async (event) => {
25
- this.log.info('Received event from voicer', event);
26
- switch (event.params.type) {
27
- case 'tts-chunks-playback-done': {
28
- this.log.info('tts-chunks-playback-done', event.params);
29
- return this.exitStep('next', {}, false);
30
- }
31
- case 'timeout': {
32
- this.log.info('timeout', event.params);
33
- return this.exitStep(event.params.type, {}, false);
34
- }
35
- case 'recognition': {
36
- this.log.info('recognition', event.params);
37
- const params = event.params;
38
- const exitData = this.exitChoiceData('voice', params);
39
- this.log.info('exitData', exitData);
40
- return this.exitStep(event.params.type, exitData, false);
41
- }
42
- case 'hangup': {
43
- await this.handleHangup(call);
44
- return await this.waitConvEnd();
45
- }
46
- case 'cancel': {
47
- return this.handleCancel();
48
- }
49
- case 'error':
50
- return this.throwError(event.params.error);
51
- }
52
- });
53
- this.triggers.otherwise(async () => {
54
- await this.pauseRecording(call, command);
55
- return this.exitFlow();
56
- });
57
- }
58
- }
59
- exports.default = StartTTSChunksProcessing;