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.mjs CHANGED
@@ -279,6 +279,49 @@ var BaseAdapter = class {
279
279
  // src/adapters/gladia-adapter.ts
280
280
  import axios from "axios";
281
281
  import WebSocket from "ws";
282
+
283
+ // src/router/audio-encoding-types.ts
284
+ var GLADIA_ENCODING_MAP = {
285
+ linear16: "wav/pcm",
286
+ mulaw: "wav/ulaw",
287
+ alaw: "wav/alaw"
288
+ };
289
+ var DEEPGRAM_ENCODING_MAP = {
290
+ linear16: "linear16",
291
+ mulaw: "mulaw",
292
+ flac: "flac",
293
+ opus: "opus",
294
+ speex: "speex",
295
+ "amr-nb": "amr-nb",
296
+ "amr-wb": "amr-wb",
297
+ g729: "g729"
298
+ };
299
+ var ASSEMBLYAI_ENCODING_MAP = {
300
+ linear16: "pcm_s16le"
301
+ };
302
+ function mapEncodingToProvider(unifiedEncoding, provider) {
303
+ let mapping;
304
+ switch (provider) {
305
+ case "gladia":
306
+ mapping = GLADIA_ENCODING_MAP;
307
+ break;
308
+ case "deepgram":
309
+ mapping = DEEPGRAM_ENCODING_MAP;
310
+ break;
311
+ case "assemblyai":
312
+ mapping = ASSEMBLYAI_ENCODING_MAP;
313
+ break;
314
+ }
315
+ const providerEncoding = mapping[unifiedEncoding];
316
+ if (!providerEncoding) {
317
+ throw new Error(
318
+ `Encoding '${unifiedEncoding}' is not supported by ${provider}. Supported encodings: ${Object.keys(mapping).join(", ")}`
319
+ );
320
+ }
321
+ return providerEncoding;
322
+ }
323
+
324
+ // src/adapters/gladia-adapter.ts
282
325
  var GladiaAdapter = class extends BaseAdapter {
283
326
  constructor() {
284
327
  super(...arguments);
@@ -666,7 +709,9 @@ var GladiaAdapter = class extends BaseAdapter {
666
709
  async transcribeStream(options, callbacks) {
667
710
  this.validateConfig();
668
711
  const streamingRequest = {
669
- encoding: options?.encoding,
712
+ // Map unified encoding format to Gladia's provider-specific format
713
+ // e.g., 'linear16' → 'wav/pcm'
714
+ encoding: options?.encoding ? mapEncodingToProvider(options.encoding, "gladia") : void 0,
670
715
  sample_rate: options?.sampleRate,
671
716
  channels: options?.channels,
672
717
  endpointing: options?.endpointing
@@ -676,10 +721,7 @@ var GladiaAdapter = class extends BaseAdapter {
676
721
  languages: [options.language]
677
722
  };
678
723
  }
679
- const initResponse = await this.client.post(
680
- "/v2/live",
681
- streamingRequest
682
- );
724
+ const initResponse = await this.client.post("/live", streamingRequest);
683
725
  const { id, url: wsUrl } = initResponse.data;
684
726
  const ws = new WebSocket(wsUrl);
685
727
  let sessionStatus = "connecting";
@@ -3983,11 +4025,6 @@ var SummaryTypesEnum = {
3983
4025
  concise: "concise"
3984
4026
  };
3985
4027
 
3986
- // src/generated/gladia/schema/transcriptMessageType.ts
3987
- var TranscriptMessageType = {
3988
- transcript: "transcript"
3989
- };
3990
-
3991
4028
  // src/generated/gladia/schema/transcriptionControllerListV2KindItem.ts
3992
4029
  var TranscriptionControllerListV2KindItem = {
3993
4030
  "pre-recorded": "pre-recorded",
@@ -4105,6 +4142,11 @@ var TranscriptionLanguageCodeEnum = {
4105
4142
  zh: "zh"
4106
4143
  };
4107
4144
 
4145
+ // src/generated/gladia/schema/transcriptMessageType.ts
4146
+ var TranscriptMessageType = {
4147
+ transcript: "transcript"
4148
+ };
4149
+
4108
4150
  // src/generated/gladia/schema/translationLanguageCodeEnum.ts
4109
4151
  var TranslationLanguageCodeEnum = {
4110
4152
  af: "af",