@absolutejs/voice 0.0.22-beta.471 → 0.0.22-beta.473
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/README.md +41 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1497 -0
- package/dist/monitor.d.ts +138 -0
- package/dist/multilingualProof.d.ts +77 -0
- package/package.json +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Elysia } from "elysia";
|
|
2
|
+
import type { AudioFormat, VoiceSessionHandle, VoiceSessionRecord } from "./types";
|
|
3
|
+
export type VoiceMonitorAudioSource = "assistant" | "caller" | (string & {});
|
|
4
|
+
export type VoiceMonitorAudioEvent = {
|
|
5
|
+
at: number;
|
|
6
|
+
chunk: Uint8Array;
|
|
7
|
+
format: AudioFormat;
|
|
8
|
+
source: VoiceMonitorAudioSource;
|
|
9
|
+
};
|
|
10
|
+
export type VoiceMonitorSessionRecord = {
|
|
11
|
+
handle: VoiceSessionHandle<unknown, VoiceSessionRecord, unknown>;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
onAudio: (handler: (event: VoiceMonitorAudioEvent) => void) => () => void;
|
|
14
|
+
onClose: (handler: (reason?: string) => void) => () => void;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
};
|
|
17
|
+
export type VoiceMonitorRegistry = {
|
|
18
|
+
get: (sessionId: string) => VoiceMonitorSessionRecord | undefined;
|
|
19
|
+
list: () => readonly {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
export type VoiceMonitorMutableRegistry = VoiceMonitorRegistry & {
|
|
24
|
+
emit: (sessionId: string, event: VoiceMonitorAudioEvent) => void;
|
|
25
|
+
emitClose: (sessionId: string, reason?: string) => void;
|
|
26
|
+
register: (record: VoiceMonitorSessionRecord) => () => void;
|
|
27
|
+
};
|
|
28
|
+
export type VoiceMonitorRegistryRegisterInput = {
|
|
29
|
+
handle: VoiceSessionHandle<unknown, VoiceSessionRecord, unknown>;
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
31
|
+
sessionId: string;
|
|
32
|
+
};
|
|
33
|
+
export declare const createVoiceMonitorSession: (input: VoiceMonitorRegistryRegisterInput) => VoiceMonitorSessionRecord & {
|
|
34
|
+
emit: (event: VoiceMonitorAudioEvent) => void;
|
|
35
|
+
emitClose: (reason?: string) => void;
|
|
36
|
+
};
|
|
37
|
+
export declare const createVoiceInMemoryMonitorRegistry: () => VoiceMonitorMutableRegistry;
|
|
38
|
+
export type VoiceMonitorControlMessage = {
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
reason?: string;
|
|
41
|
+
target: string;
|
|
42
|
+
type: "transfer";
|
|
43
|
+
} | {
|
|
44
|
+
reason?: string;
|
|
45
|
+
type: "hangup";
|
|
46
|
+
} | {
|
|
47
|
+
metadata?: Record<string, unknown>;
|
|
48
|
+
reason?: string;
|
|
49
|
+
type: "escalate";
|
|
50
|
+
} | {
|
|
51
|
+
metadata?: Record<string, unknown>;
|
|
52
|
+
type: "voicemail";
|
|
53
|
+
} | {
|
|
54
|
+
metadata?: Record<string, unknown>;
|
|
55
|
+
type: "no-answer";
|
|
56
|
+
} | {
|
|
57
|
+
muted: boolean;
|
|
58
|
+
target: "assistant" | "caller";
|
|
59
|
+
type: "mute";
|
|
60
|
+
} | {
|
|
61
|
+
interrupt?: boolean;
|
|
62
|
+
text: string;
|
|
63
|
+
type: "say";
|
|
64
|
+
} | {
|
|
65
|
+
role: "assistant" | "system" | "user";
|
|
66
|
+
text: string;
|
|
67
|
+
type: "inject";
|
|
68
|
+
};
|
|
69
|
+
export type VoiceMonitorControlAck = {
|
|
70
|
+
detail?: string;
|
|
71
|
+
ok: true;
|
|
72
|
+
type: VoiceMonitorControlMessage["type"];
|
|
73
|
+
} | {
|
|
74
|
+
error: string;
|
|
75
|
+
ok: false;
|
|
76
|
+
type: VoiceMonitorControlMessage["type"];
|
|
77
|
+
};
|
|
78
|
+
export type VoiceMonitorControlHandlerInput = {
|
|
79
|
+
message: VoiceMonitorControlMessage;
|
|
80
|
+
raw: unknown;
|
|
81
|
+
session: VoiceMonitorSessionRecord;
|
|
82
|
+
};
|
|
83
|
+
export type VoiceMonitorControlHandler = (input: VoiceMonitorControlHandlerInput) => Promise<VoiceMonitorControlAck> | VoiceMonitorControlAck;
|
|
84
|
+
export type VoiceMonitorAuthenticateInput = {
|
|
85
|
+
request: unknown;
|
|
86
|
+
route: "control" | "listen";
|
|
87
|
+
sessionId: string;
|
|
88
|
+
};
|
|
89
|
+
export type VoiceMonitorAuthenticate = (input: VoiceMonitorAuthenticateInput) => boolean | Promise<boolean>;
|
|
90
|
+
export type VoiceLiveMonitorRoutesOptions = {
|
|
91
|
+
authenticate?: VoiceMonitorAuthenticate;
|
|
92
|
+
basePath?: string;
|
|
93
|
+
controlHandlers?: Partial<Record<VoiceMonitorControlMessage["type"], VoiceMonitorControlHandler>>;
|
|
94
|
+
controlPath?: false | string;
|
|
95
|
+
htmlPath?: false | string;
|
|
96
|
+
listenPath?: false | string;
|
|
97
|
+
registry: VoiceMonitorRegistry;
|
|
98
|
+
};
|
|
99
|
+
export type VoiceMonitorPlanInput = {
|
|
100
|
+
basePath?: string;
|
|
101
|
+
baseUrl: string;
|
|
102
|
+
controlPath?: string;
|
|
103
|
+
listenPath?: string;
|
|
104
|
+
sessionId: string;
|
|
105
|
+
};
|
|
106
|
+
export type VoiceMonitorPlan = {
|
|
107
|
+
controlUrl: string;
|
|
108
|
+
listenUrl: string;
|
|
109
|
+
};
|
|
110
|
+
export declare const buildVoiceMonitorPlan: (input: VoiceMonitorPlanInput) => VoiceMonitorPlan;
|
|
111
|
+
export declare const createVoiceLiveMonitorRoutes: (options: VoiceLiveMonitorRoutesOptions) => Elysia<"", {
|
|
112
|
+
decorator: {};
|
|
113
|
+
store: {};
|
|
114
|
+
derive: {};
|
|
115
|
+
resolve: {};
|
|
116
|
+
}, {
|
|
117
|
+
typebox: {};
|
|
118
|
+
error: {};
|
|
119
|
+
}, {
|
|
120
|
+
schema: {};
|
|
121
|
+
standaloneSchema: {};
|
|
122
|
+
macro: {};
|
|
123
|
+
macroFn: {};
|
|
124
|
+
parser: {};
|
|
125
|
+
response: {};
|
|
126
|
+
}, {}, {
|
|
127
|
+
derive: {};
|
|
128
|
+
resolve: {};
|
|
129
|
+
schema: {};
|
|
130
|
+
standaloneSchema: {};
|
|
131
|
+
response: {};
|
|
132
|
+
}, {
|
|
133
|
+
derive: {};
|
|
134
|
+
resolve: {};
|
|
135
|
+
schema: {};
|
|
136
|
+
standaloneSchema: {};
|
|
137
|
+
response: {};
|
|
138
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { STTAdapter } from "./types";
|
|
2
|
+
import { type VoiceTestFixture } from "./testing/fixtures";
|
|
3
|
+
import { type VoiceSTTBenchmarkOptions, type VoiceSTTBenchmarkReport } from "./testing/benchmark";
|
|
4
|
+
export type VoiceMultilingualLanguageCode = string;
|
|
5
|
+
export type VoiceMultilingualProofLanguageThresholds = {
|
|
6
|
+
label?: string;
|
|
7
|
+
language: VoiceMultilingualLanguageCode;
|
|
8
|
+
maxAverageWordErrorRate?: number;
|
|
9
|
+
minAverageWordAccuracyRate?: number;
|
|
10
|
+
minPassRate?: number;
|
|
11
|
+
minTermRecall?: number;
|
|
12
|
+
};
|
|
13
|
+
export type VoiceMultilingualProofDefaultThresholds = Omit<VoiceMultilingualProofLanguageThresholds, "label" | "language">;
|
|
14
|
+
export type VoiceMultilingualProofAdapterEntry = {
|
|
15
|
+
adapter: STTAdapter;
|
|
16
|
+
adapterId: string;
|
|
17
|
+
benchmarkOptions?: VoiceSTTBenchmarkOptions;
|
|
18
|
+
};
|
|
19
|
+
export type VoiceMultilingualProofOptions = {
|
|
20
|
+
adapters: readonly VoiceMultilingualProofAdapterEntry[];
|
|
21
|
+
defaultThresholds?: VoiceMultilingualProofDefaultThresholds;
|
|
22
|
+
filter?: (fixture: VoiceTestFixture) => boolean;
|
|
23
|
+
fixtureDirectories?: string | readonly string[];
|
|
24
|
+
fixtures?: readonly VoiceTestFixture[];
|
|
25
|
+
perLanguage?: readonly VoiceMultilingualProofLanguageThresholds[];
|
|
26
|
+
};
|
|
27
|
+
export type VoiceMultilingualProofLanguageMetrics = {
|
|
28
|
+
averageTermRecall: number;
|
|
29
|
+
averageWordAccuracyRate: number;
|
|
30
|
+
averageWordErrorRate: number;
|
|
31
|
+
fixtureCount: number;
|
|
32
|
+
passCount: number;
|
|
33
|
+
passRate: number;
|
|
34
|
+
};
|
|
35
|
+
export type VoiceMultilingualProofLanguageReport = {
|
|
36
|
+
applied: VoiceMultilingualProofLanguageThresholds;
|
|
37
|
+
failures: readonly string[];
|
|
38
|
+
fixtureIds: readonly string[];
|
|
39
|
+
label?: string;
|
|
40
|
+
language: VoiceMultilingualLanguageCode;
|
|
41
|
+
metrics: VoiceMultilingualProofLanguageMetrics;
|
|
42
|
+
passes: boolean;
|
|
43
|
+
};
|
|
44
|
+
export type VoiceMultilingualProofAdapterReport = {
|
|
45
|
+
adapterId: string;
|
|
46
|
+
benchmark: VoiceSTTBenchmarkReport;
|
|
47
|
+
failures: readonly string[];
|
|
48
|
+
fixtureCount: number;
|
|
49
|
+
languageReports: readonly VoiceMultilingualProofLanguageReport[];
|
|
50
|
+
overall: VoiceMultilingualProofLanguageMetrics;
|
|
51
|
+
passes: boolean;
|
|
52
|
+
};
|
|
53
|
+
export type VoiceMultilingualProofReport = {
|
|
54
|
+
adapters: readonly VoiceMultilingualProofAdapterReport[];
|
|
55
|
+
generatedAt: number;
|
|
56
|
+
passes: boolean;
|
|
57
|
+
summary: {
|
|
58
|
+
adapterCount: number;
|
|
59
|
+
failedAdapters: readonly string[];
|
|
60
|
+
fixtureCount: number;
|
|
61
|
+
languageCount: number;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export declare const runVoiceMultilingualProof: (options: VoiceMultilingualProofOptions) => Promise<VoiceMultilingualProofReport>;
|
|
65
|
+
export declare const renderVoiceMultilingualProofMarkdown: (report: VoiceMultilingualProofReport) => string;
|
|
66
|
+
export type VoiceMultilingualProofReadinessOptions = {
|
|
67
|
+
baseHref?: string;
|
|
68
|
+
label?: string;
|
|
69
|
+
};
|
|
70
|
+
export type VoiceMultilingualProofReadinessCheck = {
|
|
71
|
+
detail: string;
|
|
72
|
+
href?: string;
|
|
73
|
+
label: string;
|
|
74
|
+
status: "fail" | "pass" | "warn";
|
|
75
|
+
value?: number | string;
|
|
76
|
+
};
|
|
77
|
+
export declare const buildVoiceMultilingualProofReadinessCheck: (report: VoiceMultilingualProofReport, options?: VoiceMultilingualProofReadinessOptions) => VoiceMultilingualProofReadinessCheck;
|