@volley/recognition-client-sdk 0.1.200 → 0.1.210

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.
@@ -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-CDQ_TzeH.js';
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);