whio-api-sdk 1.0.200-beta-staging → 1.0.202-beta-staging
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/dist/src/sdk/modules/websocket.module.d.ts +2 -2
- package/dist/src/sdk/modules/websocket.module.js +15 -8
- package/dist/src/sdk/types/websocket.types.d.ts +23 -4
- package/package.json +1 -1
- package/src/sdk/modules/websocket.module.ts +18 -10
- package/src/sdk/types/websocket.types.ts +17 -5
- package/test-websocket.mjs +2 -2
|
@@ -33,9 +33,9 @@ export declare class WebSocketModule extends BaseClient {
|
|
|
33
33
|
/**
|
|
34
34
|
* Stream audio chunk to server
|
|
35
35
|
*/
|
|
36
|
-
streamAudioChunk(sessionId: string, audioChunk: string
|
|
36
|
+
streamAudioChunk(sessionId: string, audioChunk: string): void;
|
|
37
37
|
/**
|
|
38
|
-
* Stream multiple audio chunks
|
|
38
|
+
* Stream multiple audio chunks
|
|
39
39
|
*/
|
|
40
40
|
streamAudioChunks(sessionId: string, audioChunks: string[], options?: AudioStreamingOptions): Promise<void>;
|
|
41
41
|
/**
|
|
@@ -97,20 +97,19 @@ export class WebSocketModule extends BaseClient {
|
|
|
97
97
|
/**
|
|
98
98
|
* Stream audio chunk to server
|
|
99
99
|
*/
|
|
100
|
-
streamAudioChunk(sessionId, audioChunk
|
|
100
|
+
streamAudioChunk(sessionId, audioChunk) {
|
|
101
101
|
var _a;
|
|
102
102
|
if (!((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected)) {
|
|
103
103
|
throw new Error('WebSocket not connected. Cannot stream audio chunk.');
|
|
104
104
|
}
|
|
105
105
|
const payload = {
|
|
106
106
|
sessionId,
|
|
107
|
-
audioChunk
|
|
108
|
-
flag: isEnd ? 'end' : null
|
|
107
|
+
audioChunk
|
|
109
108
|
};
|
|
110
109
|
this.socket.emit('audio-chunk', payload);
|
|
111
110
|
}
|
|
112
111
|
/**
|
|
113
|
-
* Stream multiple audio chunks
|
|
112
|
+
* Stream multiple audio chunks
|
|
114
113
|
*/
|
|
115
114
|
streamAudioChunks(sessionId, audioChunks, options = {}) {
|
|
116
115
|
var _a;
|
|
@@ -118,12 +117,11 @@ export class WebSocketModule extends BaseClient {
|
|
|
118
117
|
if (!((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected)) {
|
|
119
118
|
throw new Error('WebSocket not connected. Cannot stream audio chunks.');
|
|
120
119
|
}
|
|
121
|
-
const delay = options.
|
|
120
|
+
const delay = options.delayBetweenChunks || 100; // ms between chunks
|
|
122
121
|
for (let i = 0; i < audioChunks.length; i++) {
|
|
123
|
-
|
|
124
|
-
this.streamAudioChunk(sessionId, audioChunks[i], isLastChunk);
|
|
122
|
+
this.streamAudioChunk(sessionId, audioChunks[i]);
|
|
125
123
|
// Small delay between chunks to prevent overwhelming the server
|
|
126
|
-
if (
|
|
124
|
+
if (i < audioChunks.length - 1) {
|
|
127
125
|
yield new Promise(resolve => setTimeout(resolve, delay));
|
|
128
126
|
}
|
|
129
127
|
}
|
|
@@ -204,9 +202,18 @@ export class WebSocketModule extends BaseClient {
|
|
|
204
202
|
this.socket.on('audio-chunk-received', (data) => {
|
|
205
203
|
this.emit('audio-chunk-received', data);
|
|
206
204
|
});
|
|
205
|
+
this.socket.on('transcription-complete', (data) => {
|
|
206
|
+
this.emit('transcription-complete', data);
|
|
207
|
+
});
|
|
207
208
|
this.socket.on('transcription-queued', (data) => {
|
|
208
209
|
this.emit('transcription-queued', data);
|
|
209
210
|
});
|
|
211
|
+
this.socket.on('summary-complete', (data) => {
|
|
212
|
+
this.emit('summary-complete', data);
|
|
213
|
+
});
|
|
214
|
+
this.socket.on('summary-queued', (data) => {
|
|
215
|
+
this.emit('summary-queued', data);
|
|
216
|
+
});
|
|
210
217
|
this.socket.on('audio-error', (error) => {
|
|
211
218
|
this.emit('audio-error', error);
|
|
212
219
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export interface AudioChunkPayload {
|
|
2
2
|
sessionId: string;
|
|
3
3
|
audioChunk: string;
|
|
4
|
-
flag: 'end' | null;
|
|
5
4
|
}
|
|
6
5
|
export interface WebSocketConfig {
|
|
7
6
|
autoConnect?: boolean;
|
|
@@ -17,8 +16,7 @@ export interface WebSocketConnectionStats {
|
|
|
17
16
|
lastDisconnectedAt?: Date;
|
|
18
17
|
}
|
|
19
18
|
export interface AudioStreamingOptions {
|
|
20
|
-
|
|
21
|
-
autoTranscribe?: boolean;
|
|
19
|
+
delayBetweenChunks?: number;
|
|
22
20
|
}
|
|
23
21
|
export interface WebSocketEvents {
|
|
24
22
|
connected: (data: {
|
|
@@ -29,7 +27,7 @@ export interface WebSocketEvents {
|
|
|
29
27
|
disconnected: (reason: string) => void;
|
|
30
28
|
'audio-chunk-received': (data: {
|
|
31
29
|
sessionId: string;
|
|
32
|
-
chunkCount
|
|
30
|
+
chunkCount?: number;
|
|
33
31
|
timestamp: string;
|
|
34
32
|
}) => void;
|
|
35
33
|
'transcription-queued': (data: {
|
|
@@ -37,7 +35,28 @@ export interface WebSocketEvents {
|
|
|
37
35
|
message: string;
|
|
38
36
|
timestamp: string;
|
|
39
37
|
}) => void;
|
|
38
|
+
'transcription-complete': (data: {
|
|
39
|
+
sessionId: string;
|
|
40
|
+
timestamp: string;
|
|
41
|
+
}) => void;
|
|
42
|
+
'summary-complete': (data: {
|
|
43
|
+
sessionId: string;
|
|
44
|
+
timestamp: string;
|
|
45
|
+
}) => void;
|
|
46
|
+
'summary-queued': (data: {
|
|
47
|
+
sessionId: string;
|
|
48
|
+
timestamp: string;
|
|
49
|
+
}) => void;
|
|
50
|
+
'audio-started': (data: {
|
|
51
|
+
sessionId: string;
|
|
52
|
+
timestamp: string;
|
|
53
|
+
}) => void;
|
|
54
|
+
'audio-stopped': (data: {
|
|
55
|
+
sessionId: string;
|
|
56
|
+
timestamp: string;
|
|
57
|
+
}) => void;
|
|
40
58
|
'audio-error': (error: {
|
|
59
|
+
sessionId: string;
|
|
41
60
|
error: string;
|
|
42
61
|
}) => void;
|
|
43
62
|
'transcription-error': (error: {
|
package/package.json
CHANGED
|
@@ -122,8 +122,7 @@ export class WebSocketModule extends BaseClient {
|
|
|
122
122
|
*/
|
|
123
123
|
public streamAudioChunk(
|
|
124
124
|
sessionId: string,
|
|
125
|
-
audioChunk: string
|
|
126
|
-
isEnd: boolean = false
|
|
125
|
+
audioChunk: string
|
|
127
126
|
): void {
|
|
128
127
|
if (!this.socket?.connected) {
|
|
129
128
|
throw new Error('WebSocket not connected. Cannot stream audio chunk.');
|
|
@@ -131,15 +130,14 @@ export class WebSocketModule extends BaseClient {
|
|
|
131
130
|
|
|
132
131
|
const payload: AudioChunkPayload = {
|
|
133
132
|
sessionId,
|
|
134
|
-
audioChunk
|
|
135
|
-
flag: isEnd ? 'end' : null
|
|
133
|
+
audioChunk
|
|
136
134
|
};
|
|
137
135
|
|
|
138
136
|
this.socket.emit('audio-chunk', payload);
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
/**
|
|
142
|
-
* Stream multiple audio chunks
|
|
140
|
+
* Stream multiple audio chunks
|
|
143
141
|
*/
|
|
144
142
|
public async streamAudioChunks(
|
|
145
143
|
sessionId: string,
|
|
@@ -150,15 +148,13 @@ export class WebSocketModule extends BaseClient {
|
|
|
150
148
|
throw new Error('WebSocket not connected. Cannot stream audio chunks.');
|
|
151
149
|
}
|
|
152
150
|
|
|
153
|
-
const delay = options.
|
|
151
|
+
const delay = options.delayBetweenChunks || 100; // ms between chunks
|
|
154
152
|
|
|
155
153
|
for (let i = 0; i < audioChunks.length; i++) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.streamAudioChunk(sessionId, audioChunks[i], isLastChunk);
|
|
154
|
+
this.streamAudioChunk(sessionId, audioChunks[i]);
|
|
159
155
|
|
|
160
156
|
// Small delay between chunks to prevent overwhelming the server
|
|
161
|
-
if (
|
|
157
|
+
if (i < audioChunks.length - 1) {
|
|
162
158
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
163
159
|
}
|
|
164
160
|
}
|
|
@@ -259,9 +255,21 @@ export class WebSocketModule extends BaseClient {
|
|
|
259
255
|
this.emit('audio-chunk-received', data);
|
|
260
256
|
});
|
|
261
257
|
|
|
258
|
+
this.socket.on('transcription-complete', (data: any) => {
|
|
259
|
+
this.emit('transcription-complete', data);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
262
|
this.socket.on('transcription-queued', (data: any) => {
|
|
263
263
|
this.emit('transcription-queued', data);
|
|
264
264
|
});
|
|
265
|
+
|
|
266
|
+
this.socket.on('summary-complete', (data: any) => {
|
|
267
|
+
this.emit('summary-complete', data);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
this.socket.on('summary-queued', (data: any) => {
|
|
271
|
+
this.emit('summary-queued', data);
|
|
272
|
+
});
|
|
265
273
|
|
|
266
274
|
this.socket.on('audio-error', (error: any) => {
|
|
267
275
|
this.emit('audio-error', error);
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
export interface AudioChunkPayload {
|
|
4
4
|
sessionId: string;
|
|
5
5
|
audioChunk: string; // Base64 encoded audio data
|
|
6
|
-
flag: 'end' | null;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
export interface WebSocketConfig {
|
|
@@ -22,8 +21,7 @@ export interface WebSocketConnectionStats {
|
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export interface AudioStreamingOptions {
|
|
25
|
-
|
|
26
|
-
autoTranscribe?: boolean;
|
|
24
|
+
delayBetweenChunks?: number; // Delay in ms between sending chunks
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
// WebSocket events
|
|
@@ -32,7 +30,7 @@ export interface WebSocketEvents {
|
|
|
32
30
|
disconnected: (reason: string) => void;
|
|
33
31
|
'audio-chunk-received': (data: {
|
|
34
32
|
sessionId: string;
|
|
35
|
-
chunkCount
|
|
33
|
+
chunkCount?: number;
|
|
36
34
|
timestamp: string;
|
|
37
35
|
}) => void;
|
|
38
36
|
'transcription-queued': (data: {
|
|
@@ -40,7 +38,21 @@ export interface WebSocketEvents {
|
|
|
40
38
|
message: string;
|
|
41
39
|
timestamp: string;
|
|
42
40
|
}) => void;
|
|
43
|
-
'
|
|
41
|
+
'transcription-complete': (data: {
|
|
42
|
+
sessionId: string;
|
|
43
|
+
timestamp: string;
|
|
44
|
+
}) => void;
|
|
45
|
+
'summary-complete': (data: {
|
|
46
|
+
sessionId: string;
|
|
47
|
+
timestamp: string;
|
|
48
|
+
}) => void;
|
|
49
|
+
'summary-queued': (data: {
|
|
50
|
+
sessionId: string;
|
|
51
|
+
timestamp: string;
|
|
52
|
+
}) => void;
|
|
53
|
+
'audio-started': (data: { sessionId: string; timestamp: string }) => void;
|
|
54
|
+
'audio-stopped': (data: { sessionId: string; timestamp: string }) => void;
|
|
55
|
+
'audio-error': (error: { sessionId: string; error: string }) => void;
|
|
44
56
|
'transcription-error': (error: { sessionId: string; error: string }) => void;
|
|
45
57
|
'connection-error': (error: Error) => void;
|
|
46
58
|
'reconnecting': (attemptNumber: number) => void;
|
package/test-websocket.mjs
CHANGED
|
@@ -57,7 +57,7 @@ async function testWebSocketIntegration() {
|
|
|
57
57
|
|
|
58
58
|
// Test error handling for streaming without connection
|
|
59
59
|
try {
|
|
60
|
-
sdk.streamAudioChunk('test-session',
|
|
60
|
+
sdk.streamAudioChunk('test-session', 'dGVzdC1hdWRpby1kYXRh'); // base64 test data
|
|
61
61
|
console.log('✗ Should have thrown error for streaming without connection');
|
|
62
62
|
} catch (error) {
|
|
63
63
|
console.log('✓ Correctly throws error when streaming without connection:', error.message);
|
|
@@ -86,7 +86,7 @@ sdk.onWebSocketEvent('audio-chunk-received', (data) => {
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
// Stream audio data
|
|
89
|
-
sdk.streamAudioChunk('session-id',
|
|
89
|
+
sdk.streamAudioChunk('session-id', audioBase64String);
|
|
90
90
|
|
|
91
91
|
// Or stream multiple chunks
|
|
92
92
|
await sdk.streamAudioChunks('session-id', [chunk1, chunk2, chunk3]);
|