@volley/recognition-client-sdk 0.1.417 → 0.1.419
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/index.js +14 -10
- package/dist/index.js.map +2 -2
- package/package.json +3 -3
- package/src/index.ts +2 -0
- package/src/simplified-vgf-recognition-client.ts +5 -14
- package/src/vgf-recognition-mapper.spec.ts +78 -0
- package/src/vgf-recognition-mapper.ts +29 -0
- package/dist/browser.bundled.d.ts +0 -1185
- package/dist/browser.d.ts +0 -10
- package/dist/browser.d.ts.map +0 -1
- package/dist/config-builder.d.ts +0 -134
- package/dist/config-builder.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -41
- package/dist/errors.d.ts.map +0 -1
- package/dist/factory.d.ts +0 -36
- package/dist/factory.d.ts.map +0 -1
- package/dist/index.bundled.d.ts +0 -2371
- package/dist/index.d.ts +0 -15
- package/dist/index.d.ts.map +0 -1
- package/dist/recog-client-sdk.browser.d.ts +0 -10
- package/dist/recog-client-sdk.browser.d.ts.map +0 -1
- package/dist/recognition-client.d.ts +0 -124
- package/dist/recognition-client.d.ts.map +0 -1
- package/dist/recognition-client.types.d.ts +0 -271
- package/dist/recognition-client.types.d.ts.map +0 -1
- package/dist/simplified-vgf-recognition-client.d.ts +0 -178
- package/dist/simplified-vgf-recognition-client.d.ts.map +0 -1
- package/dist/utils/audio-ring-buffer.d.ts +0 -69
- package/dist/utils/audio-ring-buffer.d.ts.map +0 -1
- package/dist/utils/message-handler.d.ts +0 -45
- package/dist/utils/message-handler.d.ts.map +0 -1
- package/dist/utils/url-builder.d.ts +0 -28
- package/dist/utils/url-builder.d.ts.map +0 -1
- package/dist/vgf-recognition-mapper.d.ts +0 -49
- package/dist/vgf-recognition-mapper.d.ts.map +0 -1
- package/dist/vgf-recognition-state.d.ts +0 -91
- package/dist/vgf-recognition-state.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volley/recognition-client-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.419",
|
|
4
4
|
"description": "Recognition Service TypeScript/Node.js Client SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"ts-jest": "29.4.5",
|
|
56
56
|
"typescript": "5.1.6",
|
|
57
57
|
"@recog/shared-config": "1.0.0",
|
|
58
|
+
"@recog/shared-utils": "1.0.0",
|
|
58
59
|
"@recog/websocket": "1.0.0",
|
|
59
|
-
"@recog/shared-types": "1.0.0"
|
|
60
|
-
"@recog/shared-utils": "1.0.0"
|
|
60
|
+
"@recog/shared-types": "1.0.0"
|
|
61
61
|
},
|
|
62
62
|
"keywords": [
|
|
63
63
|
"recognition",
|
package/src/index.ts
CHANGED
|
@@ -69,6 +69,8 @@ export {
|
|
|
69
69
|
isValidRecordingStatusTransition
|
|
70
70
|
} from './vgf-recognition-state.js';
|
|
71
71
|
|
|
72
|
+
export { resetRecognitionVGFState } from './vgf-recognition-mapper.js';
|
|
73
|
+
|
|
72
74
|
// Re-export WebSocket protocol types for advanced usage
|
|
73
75
|
export { AudioEncoding } from '@recog/websocket';
|
|
74
76
|
|
|
@@ -24,10 +24,10 @@ import {
|
|
|
24
24
|
createVGFStateFromConfig,
|
|
25
25
|
mapTranscriptionResultToState,
|
|
26
26
|
mapErrorToState,
|
|
27
|
-
updateStateOnStop
|
|
27
|
+
updateStateOnStop,
|
|
28
|
+
resetRecognitionVGFState
|
|
28
29
|
} from './vgf-recognition-mapper.js';
|
|
29
30
|
import { RecognitionContextTypeV1 } from '@recog/shared-types';
|
|
30
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Configuration for SimplifiedVGFRecognitionClient
|
|
@@ -170,8 +170,9 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
170
170
|
initialState.transcriptionStatus === TranscriptionStatus.ERROR ||
|
|
171
171
|
(initialState.recognitionActionProcessingState !== undefined && initialState.recognitionActionProcessingState !== RecognitionActionProcessingState.COMPLETED);
|
|
172
172
|
if (needsNewUuid) {
|
|
173
|
-
//
|
|
174
|
-
|
|
173
|
+
// Reset session state with new UUID
|
|
174
|
+
this.state = resetRecognitionVGFState(initialState);
|
|
175
|
+
const newUUID = this.state.audioUtteranceId;
|
|
175
176
|
|
|
176
177
|
if (clientConfig.logger) {
|
|
177
178
|
const reason = !initialState.audioUtteranceId ? 'Missing UUID' :
|
|
@@ -180,16 +181,6 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
180
181
|
clientConfig.logger('info', `${reason} detected, generating new UUID: ${newUUID}`);
|
|
181
182
|
}
|
|
182
183
|
|
|
183
|
-
// Update state with new UUID and reset session-specific fields
|
|
184
|
-
this.state = {
|
|
185
|
-
...initialState,
|
|
186
|
-
audioUtteranceId: newUUID,
|
|
187
|
-
transcriptionStatus: TranscriptionStatus.NOT_STARTED,
|
|
188
|
-
startRecordingStatus: RecordingStatus.READY,
|
|
189
|
-
recognitionActionProcessingState: RecognitionActionProcessingState.NOT_STARTED,
|
|
190
|
-
finalTranscript: undefined
|
|
191
|
-
};
|
|
192
|
-
|
|
193
184
|
// Use new UUID in client config
|
|
194
185
|
clientConfig.audioUtteranceId = newUUID;
|
|
195
186
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for VGF Recognition Mapper functions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
resetRecognitionVGFState
|
|
7
|
+
} from './vgf-recognition-mapper.js';
|
|
8
|
+
import {
|
|
9
|
+
RecognitionState,
|
|
10
|
+
RecordingStatus,
|
|
11
|
+
TranscriptionStatus,
|
|
12
|
+
RecognitionActionProcessingState
|
|
13
|
+
} from './vgf-recognition-state.js';
|
|
14
|
+
|
|
15
|
+
describe('resetRecognitionVGFState', () => {
|
|
16
|
+
it('should generate a new UUID', () => {
|
|
17
|
+
const originalState: RecognitionState = {
|
|
18
|
+
audioUtteranceId: 'old-uuid-123',
|
|
19
|
+
pendingTranscript: '',
|
|
20
|
+
transcriptionStatus: TranscriptionStatus.FINALIZED,
|
|
21
|
+
startRecordingStatus: RecordingStatus.FINISHED,
|
|
22
|
+
recognitionActionProcessingState: RecognitionActionProcessingState.COMPLETED,
|
|
23
|
+
finalTranscript: 'hello world'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const newState = resetRecognitionVGFState(originalState);
|
|
27
|
+
|
|
28
|
+
expect(newState.audioUtteranceId).not.toBe('old-uuid-123');
|
|
29
|
+
expect(newState.audioUtteranceId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should reset session-specific fields', () => {
|
|
33
|
+
const originalState: RecognitionState = {
|
|
34
|
+
audioUtteranceId: 'old-uuid-123',
|
|
35
|
+
pendingTranscript: 'partial',
|
|
36
|
+
transcriptionStatus: TranscriptionStatus.FINALIZED,
|
|
37
|
+
startRecordingStatus: RecordingStatus.FINISHED,
|
|
38
|
+
recognitionActionProcessingState: RecognitionActionProcessingState.COMPLETED,
|
|
39
|
+
finalTranscript: 'hello world'
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const newState = resetRecognitionVGFState(originalState);
|
|
43
|
+
|
|
44
|
+
expect(newState.transcriptionStatus).toBe(TranscriptionStatus.NOT_STARTED);
|
|
45
|
+
expect(newState.startRecordingStatus).toBe(RecordingStatus.READY);
|
|
46
|
+
expect(newState.recognitionActionProcessingState).toBe(RecognitionActionProcessingState.NOT_STARTED);
|
|
47
|
+
expect(newState.finalTranscript).toBeUndefined();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should preserve non-session fields like promptSlotMap', () => {
|
|
51
|
+
const originalState: RecognitionState = {
|
|
52
|
+
audioUtteranceId: 'old-uuid-123',
|
|
53
|
+
pendingTranscript: '',
|
|
54
|
+
transcriptionStatus: TranscriptionStatus.FINALIZED,
|
|
55
|
+
promptSlotMap: { artist: ['taylor swift'], song: ['shake it off'] },
|
|
56
|
+
asrConfig: '{"provider":"deepgram"}'
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const newState = resetRecognitionVGFState(originalState);
|
|
60
|
+
|
|
61
|
+
expect(newState.promptSlotMap).toEqual({ artist: ['taylor swift'], song: ['shake it off'] });
|
|
62
|
+
expect(newState.asrConfig).toBe('{"provider":"deepgram"}');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should work with minimal state', () => {
|
|
66
|
+
const originalState: RecognitionState = {
|
|
67
|
+
audioUtteranceId: 'old-uuid',
|
|
68
|
+
pendingTranscript: ''
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const newState = resetRecognitionVGFState(originalState);
|
|
72
|
+
|
|
73
|
+
expect(newState.audioUtteranceId).not.toBe('old-uuid');
|
|
74
|
+
expect(newState.transcriptionStatus).toBe(TranscriptionStatus.NOT_STARTED);
|
|
75
|
+
expect(newState.startRecordingStatus).toBe(RecordingStatus.READY);
|
|
76
|
+
expect(newState.recognitionActionProcessingState).toBe(RecognitionActionProcessingState.NOT_STARTED);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -9,8 +9,10 @@ import {
|
|
|
9
9
|
RecognitionState,
|
|
10
10
|
RecordingStatus,
|
|
11
11
|
TranscriptionStatus,
|
|
12
|
+
RecognitionActionProcessingState,
|
|
12
13
|
createInitialRecognitionState
|
|
13
14
|
} from './vgf-recognition-state.js';
|
|
15
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
14
16
|
import {
|
|
15
17
|
ClientState,
|
|
16
18
|
IRecognitionClientConfig
|
|
@@ -142,6 +144,33 @@ export function updateStateOnStop(currentState: RecognitionState): RecognitionSt
|
|
|
142
144
|
};
|
|
143
145
|
}
|
|
144
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Resets session state with a new UUID.
|
|
149
|
+
*
|
|
150
|
+
* This creates a fresh session state while preserving non-session fields
|
|
151
|
+
* (like promptSlotMap, asrConfig, etc.)
|
|
152
|
+
*
|
|
153
|
+
* Resets:
|
|
154
|
+
* - audioUtteranceId → new UUID
|
|
155
|
+
* - transcriptionStatus → NOT_STARTED
|
|
156
|
+
* - startRecordingStatus → READY
|
|
157
|
+
* - recognitionActionProcessingState → NOT_STARTED
|
|
158
|
+
* - finalTranscript → undefined
|
|
159
|
+
*
|
|
160
|
+
* @param currentState - The current recognition state
|
|
161
|
+
* @returns A new state with reset session fields and a new UUID
|
|
162
|
+
*/
|
|
163
|
+
export function resetRecognitionVGFState(currentState: RecognitionState): RecognitionState {
|
|
164
|
+
return {
|
|
165
|
+
...currentState,
|
|
166
|
+
audioUtteranceId: uuidv4(),
|
|
167
|
+
transcriptionStatus: TranscriptionStatus.NOT_STARTED,
|
|
168
|
+
startRecordingStatus: RecordingStatus.READY,
|
|
169
|
+
recognitionActionProcessingState: RecognitionActionProcessingState.NOT_STARTED,
|
|
170
|
+
finalTranscript: undefined
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
145
174
|
/**
|
|
146
175
|
* Updates state when client becomes ready
|
|
147
176
|
*/
|