@onereach/step-voice 7.0.2-initaiconversation.8 → 7.0.2-processttschunk.0
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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import VoiceStep, { VoiceEvent } from './voice';
|
|
2
|
+
interface INPUT {
|
|
3
|
+
textChunk: string;
|
|
4
|
+
isFinal: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface EVENT extends VoiceEvent {
|
|
7
|
+
exitId?: string;
|
|
8
|
+
}
|
|
9
|
+
export default class ProcessTtsChunk extends VoiceStep<INPUT, {}, EVENT> {
|
|
10
|
+
runStep(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
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 ProcessTtsChunk extends voice_1.default {
|
|
6
|
+
async runStep() {
|
|
7
|
+
const call = await this.fetchData();
|
|
8
|
+
const { textChunk, isFinal } = this.data;
|
|
9
|
+
const command = {
|
|
10
|
+
name: 'process-tts-chunk',
|
|
11
|
+
params: {
|
|
12
|
+
chunk: textChunk,
|
|
13
|
+
isFinal
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const sensitiveData = {
|
|
17
|
+
muteStep: false,
|
|
18
|
+
muteUser: false,
|
|
19
|
+
muteBot: false,
|
|
20
|
+
};
|
|
21
|
+
this.triggers.local(`in/voice/${call.id}`, async (event) => {
|
|
22
|
+
this.log.info('Received event from voicer', event);
|
|
23
|
+
});
|
|
24
|
+
this.triggers.otherwise(async () => {
|
|
25
|
+
await this.pauseRecording(call, command, sensitiveData);
|
|
26
|
+
this.exitStep('next');
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = ProcessTtsChunk;
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import VoiceStep, { VoiceEvent } from './voice';
|
|
2
|
-
interface INPUT {
|
|
3
|
-
instructions: string;
|
|
4
|
-
temperature: number;
|
|
5
|
-
modality: 'audio' | 'text';
|
|
6
|
-
threshold: number;
|
|
7
|
-
prefixPadding: number;
|
|
8
|
-
silenceDuration: number;
|
|
9
|
-
language: string;
|
|
10
|
-
voice?: string;
|
|
11
|
-
}
|
|
12
|
-
interface EVENT extends VoiceEvent {
|
|
13
|
-
exitId?: string;
|
|
14
|
-
}
|
|
15
|
-
export default class InitAIConversation extends VoiceStep<INPUT, {}, EVENT> {
|
|
16
|
-
runStep(): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,47 +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 InitAIConversation extends voice_1.default {
|
|
6
|
-
async runStep() {
|
|
7
|
-
const call = await this.fetchData();
|
|
8
|
-
const { instructions, temperature, modality, threshold, prefixPadding, silenceDuration, language, voice } = this.data;
|
|
9
|
-
const asrSettings = {
|
|
10
|
-
enabled: true,
|
|
11
|
-
engine: `openAI`,
|
|
12
|
-
config: {
|
|
13
|
-
instructions,
|
|
14
|
-
temperature,
|
|
15
|
-
modality,
|
|
16
|
-
threshold,
|
|
17
|
-
prefixPadding,
|
|
18
|
-
silenceDuration,
|
|
19
|
-
language,
|
|
20
|
-
voice
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const grammar = {
|
|
24
|
-
id: this.currentStepId,
|
|
25
|
-
asr: asrSettings
|
|
26
|
-
};
|
|
27
|
-
const command = {
|
|
28
|
-
name: 'init-ai-conversation',
|
|
29
|
-
params: {
|
|
30
|
-
grammar,
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const sensitiveData = {
|
|
34
|
-
muteStep: false,
|
|
35
|
-
muteUser: false,
|
|
36
|
-
muteBot: false,
|
|
37
|
-
};
|
|
38
|
-
this.triggers.local(`in/voice/${call.id}`, async (event) => {
|
|
39
|
-
this.log.info('Received event from voicer', event);
|
|
40
|
-
});
|
|
41
|
-
this.triggers.otherwise(async () => {
|
|
42
|
-
await this.pauseRecording(call, command, sensitiveData);
|
|
43
|
-
return this.exitFlow();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.default = InitAIConversation;
|