voice-router-dev 0.1.1 → 0.1.3

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 CHANGED
@@ -337,6 +337,49 @@ var BaseAdapter = class {
337
337
  // src/adapters/gladia-adapter.ts
338
338
  var import_axios = __toESM(require("axios"));
339
339
  var import_ws = __toESM(require("ws"));
340
+
341
+ // src/router/audio-encoding-types.ts
342
+ var GLADIA_ENCODING_MAP = {
343
+ linear16: "wav/pcm",
344
+ mulaw: "wav/ulaw",
345
+ alaw: "wav/alaw"
346
+ };
347
+ var DEEPGRAM_ENCODING_MAP = {
348
+ linear16: "linear16",
349
+ mulaw: "mulaw",
350
+ flac: "flac",
351
+ opus: "opus",
352
+ speex: "speex",
353
+ "amr-nb": "amr-nb",
354
+ "amr-wb": "amr-wb",
355
+ g729: "g729"
356
+ };
357
+ var ASSEMBLYAI_ENCODING_MAP = {
358
+ linear16: "pcm_s16le"
359
+ };
360
+ function mapEncodingToProvider(unifiedEncoding, provider) {
361
+ let mapping;
362
+ switch (provider) {
363
+ case "gladia":
364
+ mapping = GLADIA_ENCODING_MAP;
365
+ break;
366
+ case "deepgram":
367
+ mapping = DEEPGRAM_ENCODING_MAP;
368
+ break;
369
+ case "assemblyai":
370
+ mapping = ASSEMBLYAI_ENCODING_MAP;
371
+ break;
372
+ }
373
+ const providerEncoding = mapping[unifiedEncoding];
374
+ if (!providerEncoding) {
375
+ throw new Error(
376
+ `Encoding '${unifiedEncoding}' is not supported by ${provider}. Supported encodings: ${Object.keys(mapping).join(", ")}`
377
+ );
378
+ }
379
+ return providerEncoding;
380
+ }
381
+
382
+ // src/adapters/gladia-adapter.ts
340
383
  var GladiaAdapter = class extends BaseAdapter {
341
384
  constructor() {
342
385
  super(...arguments);
@@ -724,7 +767,9 @@ var GladiaAdapter = class extends BaseAdapter {
724
767
  async transcribeStream(options, callbacks) {
725
768
  this.validateConfig();
726
769
  const streamingRequest = {
727
- encoding: options?.encoding,
770
+ // Map unified encoding format to Gladia's provider-specific format
771
+ // e.g., 'linear16' → 'wav/pcm'
772
+ encoding: options?.encoding ? mapEncodingToProvider(options.encoding, "gladia") : void 0,
728
773
  sample_rate: options?.sampleRate,
729
774
  channels: options?.channels,
730
775
  endpointing: options?.endpointing
@@ -734,10 +779,7 @@ var GladiaAdapter = class extends BaseAdapter {
734
779
  languages: [options.language]
735
780
  };
736
781
  }
737
- const initResponse = await this.client.post(
738
- "/v2/live",
739
- streamingRequest
740
- );
782
+ const initResponse = await this.client.post("/live", streamingRequest);
741
783
  const { id, url: wsUrl } = initResponse.data;
742
784
  const ws = new import_ws.default(wsUrl);
743
785
  let sessionStatus = "connecting";
@@ -4041,11 +4083,6 @@ var SummaryTypesEnum = {
4041
4083
  concise: "concise"
4042
4084
  };
4043
4085
 
4044
- // src/generated/gladia/schema/transcriptMessageType.ts
4045
- var TranscriptMessageType = {
4046
- transcript: "transcript"
4047
- };
4048
-
4049
4086
  // src/generated/gladia/schema/transcriptionControllerListV2KindItem.ts
4050
4087
  var TranscriptionControllerListV2KindItem = {
4051
4088
  "pre-recorded": "pre-recorded",
@@ -4163,6 +4200,11 @@ var TranscriptionLanguageCodeEnum = {
4163
4200
  zh: "zh"
4164
4201
  };
4165
4202
 
4203
+ // src/generated/gladia/schema/transcriptMessageType.ts
4204
+ var TranscriptMessageType = {
4205
+ transcript: "transcript"
4206
+ };
4207
+
4166
4208
  // src/generated/gladia/schema/translationLanguageCodeEnum.ts
4167
4209
  var TranslationLanguageCodeEnum = {
4168
4210
  af: "af",