@volley/recognition-client-sdk 0.1.200 → 0.1.211
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 +115 -15
- package/dist/{browser-CDQ_TzeH.d.ts → browser-C4ZssGoU.d.ts} +4 -3
- package/dist/index.d.ts +9 -5
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/dist/recog-client-sdk.browser.d.ts +1 -1
- package/dist/recog-client-sdk.browser.js +25 -8
- package/dist/recog-client-sdk.browser.js.map +1 -1
- package/package.json +16 -16
- package/src/config-builder.spec.ts +265 -0
- package/src/factory.spec.ts +215 -0
- package/src/factory.ts +4 -0
- package/src/recognition-client.spec.ts +179 -0
- package/src/recognition-client.ts +45 -2
- package/src/recognition-client.types.ts +2 -2
- package/src/simplified-vgf-recognition-client.spec.ts +6 -0
- package/src/simplified-vgf-recognition-client.ts +3 -3
- package/src/utils/message-handler.spec.ts +311 -0
- package/src/utils/url-builder.spec.ts +203 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { f as AudioEncoding, h as ControlSignal, G as GameContextV1, c as RealTimeTwoWayWebSocketRecognitionClient, a as RealTimeTwoWayWebSocketRecognitionClientConfig, g as RecognitionContextTypeV1, d as TranscriptionResult } from './browser-
|
|
1
|
+
export { f as AudioEncoding, h as ControlSignal, G as GameContextV1, c as RealTimeTwoWayWebSocketRecognitionClient, a as RealTimeTwoWayWebSocketRecognitionClientConfig, g as RecognitionContextTypeV1, d as TranscriptionResult } from './browser-C4ZssGoU.js';
|
|
2
2
|
import 'zod';
|
|
@@ -302,13 +302,7 @@ var TimerSchema = z.object({
|
|
|
302
302
|
* Total duration of all audio chunks sent to this provider session
|
|
303
303
|
* @example 2500 (2.5 seconds of audio has been sent)
|
|
304
304
|
*/
|
|
305
|
-
accumulatedAudioTimeMs: z.number().optional()
|
|
306
|
-
/**
|
|
307
|
-
* Estimated cost in USD for this session
|
|
308
|
-
* Calculated by the job based on audio duration and provider pricing
|
|
309
|
-
* @example 0.0025 (quarter of a cent)
|
|
310
|
-
*/
|
|
311
|
-
costInUSD: z.number().optional().default(0)
|
|
305
|
+
accumulatedAudioTimeMs: z.number().optional()
|
|
312
306
|
});
|
|
313
307
|
var RawMessageSchema = z.object({
|
|
314
308
|
type: z.literal(ProviderMessageType.RAW),
|
|
@@ -1442,6 +1436,18 @@ var MessageHandler = class {
|
|
|
1442
1436
|
};
|
|
1443
1437
|
|
|
1444
1438
|
// src/recognition-client.ts
|
|
1439
|
+
async function blobToArrayBuffer(blob) {
|
|
1440
|
+
if (typeof blob.arrayBuffer === "function") {
|
|
1441
|
+
return await blob.arrayBuffer();
|
|
1442
|
+
}
|
|
1443
|
+
return new Promise((resolve, reject) => {
|
|
1444
|
+
const reader = new FileReader();
|
|
1445
|
+
reader.onload = () => resolve(reader.result);
|
|
1446
|
+
reader.onerror = () => reject(reader.error);
|
|
1447
|
+
reader.readAsArrayBuffer(blob);
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
__name(blobToArrayBuffer, "blobToArrayBuffer");
|
|
1445
1451
|
var RealTimeTwoWayWebSocketRecognitionClient = class _RealTimeTwoWayWebSocketRecognitionClient extends WebSocketAudioClient {
|
|
1446
1452
|
static {
|
|
1447
1453
|
__name(this, "RealTimeTwoWayWebSocketRecognitionClient");
|
|
@@ -1631,6 +1637,17 @@ var RealTimeTwoWayWebSocketRecognitionClient = class _RealTimeTwoWayWebSocketRec
|
|
|
1631
1637
|
return this.connectionPromise;
|
|
1632
1638
|
}
|
|
1633
1639
|
sendAudio(audioData) {
|
|
1640
|
+
if (audioData instanceof Blob) {
|
|
1641
|
+
blobToArrayBuffer(audioData).then((arrayBuffer) => {
|
|
1642
|
+
this.sendAudioInternal(arrayBuffer);
|
|
1643
|
+
}).catch((error) => {
|
|
1644
|
+
this.log("error", "Failed to convert Blob to ArrayBuffer", error);
|
|
1645
|
+
});
|
|
1646
|
+
return;
|
|
1647
|
+
}
|
|
1648
|
+
this.sendAudioInternal(audioData);
|
|
1649
|
+
}
|
|
1650
|
+
sendAudioInternal(audioData) {
|
|
1634
1651
|
const bytes = ArrayBuffer.isView(audioData) ? audioData.byteLength : audioData.byteLength;
|
|
1635
1652
|
if (bytes === 0) return;
|
|
1636
1653
|
this.audioBuffer.write(audioData);
|
|
@@ -1662,7 +1679,7 @@ var RealTimeTwoWayWebSocketRecognitionClient = class _RealTimeTwoWayWebSocketRec
|
|
|
1662
1679
|
}
|
|
1663
1680
|
async stopRecording() {
|
|
1664
1681
|
if (this.state !== ClientState.READY) {
|
|
1665
|
-
this.log("
|
|
1682
|
+
this.log("debug", "stopRecording called but not in READY state", {
|
|
1666
1683
|
state: this.state
|
|
1667
1684
|
});
|
|
1668
1685
|
return;
|