voice-router-dev 0.1.8 → 0.1.9
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 +138 -4
- package/dist/index.d.mts +8917 -7571
- package/dist/index.d.ts +8917 -7571
- package/dist/index.js +115 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -43,9 +43,16 @@ __export(src_exports, {
|
|
|
43
43
|
GladiaAdapter: () => GladiaAdapter,
|
|
44
44
|
GladiaTypes: () => schema_exports,
|
|
45
45
|
GladiaWebhookHandler: () => GladiaWebhookHandler,
|
|
46
|
+
ListenV1EncodingParameter: () => ListenV1EncodingParameter,
|
|
46
47
|
OpenAIWhisperAdapter: () => OpenAIWhisperAdapter,
|
|
48
|
+
SpeakV1ContainerParameter: () => SpeakV1ContainerParameter,
|
|
49
|
+
SpeakV1EncodingParameter: () => SpeakV1EncodingParameter,
|
|
50
|
+
SpeakV1SampleRateParameter: () => SpeakV1SampleRateParameter,
|
|
47
51
|
SpeechmaticsAdapter: () => SpeechmaticsAdapter,
|
|
48
52
|
SpeechmaticsWebhookHandler: () => SpeechmaticsWebhookHandler,
|
|
53
|
+
StreamingSupportedBitDepthEnum: () => StreamingSupportedBitDepthEnum,
|
|
54
|
+
StreamingSupportedEncodingEnum: () => StreamingSupportedEncodingEnum,
|
|
55
|
+
StreamingSupportedSampleRateEnum: () => StreamingSupportedSampleRateEnum,
|
|
49
56
|
VoiceRouter: () => VoiceRouter,
|
|
50
57
|
WebhookRouter: () => WebhookRouter,
|
|
51
58
|
createAssemblyAIAdapter: () => createAssemblyAIAdapter,
|
|
@@ -268,6 +275,69 @@ function createVoiceRouter(config, adapters) {
|
|
|
268
275
|
return router;
|
|
269
276
|
}
|
|
270
277
|
|
|
278
|
+
// src/generated/deepgram/schema/listenV1EncodingParameter.ts
|
|
279
|
+
var ListenV1EncodingParameter = {
|
|
280
|
+
linear16: "linear16",
|
|
281
|
+
flac: "flac",
|
|
282
|
+
mulaw: "mulaw",
|
|
283
|
+
opus: "opus",
|
|
284
|
+
speex: "speex",
|
|
285
|
+
g729: "g729"
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
// src/generated/deepgram/schema/speakV1EncodingParameter.ts
|
|
289
|
+
var SpeakV1EncodingParameter = {
|
|
290
|
+
linear16: "linear16",
|
|
291
|
+
aac: "aac",
|
|
292
|
+
opus: "opus",
|
|
293
|
+
mp3: "mp3",
|
|
294
|
+
flac: "flac",
|
|
295
|
+
mulaw: "mulaw",
|
|
296
|
+
alaw: "alaw"
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// src/generated/deepgram/schema/speakV1ContainerParameter.ts
|
|
300
|
+
var SpeakV1ContainerParameter = {
|
|
301
|
+
none: "none",
|
|
302
|
+
wav: "wav",
|
|
303
|
+
ogg: "ogg"
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// src/generated/deepgram/schema/speakV1SampleRateParameter.ts
|
|
307
|
+
var SpeakV1SampleRateParameter = {
|
|
308
|
+
NUMBER_16000: 16e3,
|
|
309
|
+
NUMBER_24000: 24e3,
|
|
310
|
+
NUMBER_32000: 32e3,
|
|
311
|
+
NUMBER_48000: 48e3,
|
|
312
|
+
null: null,
|
|
313
|
+
NUMBER_8000: 8e3,
|
|
314
|
+
NUMBER_22050: 22050
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
// src/generated/gladia/schema/streamingSupportedEncodingEnum.ts
|
|
318
|
+
var StreamingSupportedEncodingEnum = {
|
|
319
|
+
"wav/pcm": "wav/pcm",
|
|
320
|
+
"wav/alaw": "wav/alaw",
|
|
321
|
+
"wav/ulaw": "wav/ulaw"
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// src/generated/gladia/schema/streamingSupportedSampleRateEnum.ts
|
|
325
|
+
var StreamingSupportedSampleRateEnum = {
|
|
326
|
+
NUMBER_8000: 8e3,
|
|
327
|
+
NUMBER_16000: 16e3,
|
|
328
|
+
NUMBER_32000: 32e3,
|
|
329
|
+
NUMBER_44100: 44100,
|
|
330
|
+
NUMBER_48000: 48e3
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
// src/generated/gladia/schema/streamingSupportedBitDepthEnum.ts
|
|
334
|
+
var StreamingSupportedBitDepthEnum = {
|
|
335
|
+
NUMBER_8: 8,
|
|
336
|
+
NUMBER_16: 16,
|
|
337
|
+
NUMBER_24: 24,
|
|
338
|
+
NUMBER_32: 32
|
|
339
|
+
};
|
|
340
|
+
|
|
271
341
|
// src/constants/defaults.ts
|
|
272
342
|
var DEFAULT_TIMEOUTS = {
|
|
273
343
|
/** Standard HTTP request timeout for API calls (60 seconds) */
|
|
@@ -1155,21 +1225,6 @@ var StreamingResponseStatus = {
|
|
|
1155
1225
|
error: "error"
|
|
1156
1226
|
};
|
|
1157
1227
|
|
|
1158
|
-
// src/generated/gladia/schema/streamingSupportedBitDepthEnum.ts
|
|
1159
|
-
var StreamingSupportedBitDepthEnum = {
|
|
1160
|
-
NUMBER_8: 8,
|
|
1161
|
-
NUMBER_16: 16,
|
|
1162
|
-
NUMBER_24: 24,
|
|
1163
|
-
NUMBER_32: 32
|
|
1164
|
-
};
|
|
1165
|
-
|
|
1166
|
-
// src/generated/gladia/schema/streamingSupportedEncodingEnum.ts
|
|
1167
|
-
var StreamingSupportedEncodingEnum = {
|
|
1168
|
-
"wav/pcm": "wav/pcm",
|
|
1169
|
-
"wav/alaw": "wav/alaw",
|
|
1170
|
-
"wav/ulaw": "wav/ulaw"
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
1228
|
// src/generated/gladia/schema/streamingSupportedModels.ts
|
|
1174
1229
|
var StreamingSupportedModels = {
|
|
1175
1230
|
"solaria-1": "solaria-1"
|
|
@@ -1181,15 +1236,6 @@ var StreamingSupportedRegions = {
|
|
|
1181
1236
|
"eu-west": "eu-west"
|
|
1182
1237
|
};
|
|
1183
1238
|
|
|
1184
|
-
// src/generated/gladia/schema/streamingSupportedSampleRateEnum.ts
|
|
1185
|
-
var StreamingSupportedSampleRateEnum = {
|
|
1186
|
-
NUMBER_8000: 8e3,
|
|
1187
|
-
NUMBER_16000: 16e3,
|
|
1188
|
-
NUMBER_32000: 32e3,
|
|
1189
|
-
NUMBER_44100: 44100,
|
|
1190
|
-
NUMBER_48000: 48e3
|
|
1191
|
-
};
|
|
1192
|
-
|
|
1193
1239
|
// src/generated/gladia/schema/subtitlesFormatEnum.ts
|
|
1194
1240
|
var SubtitlesFormatEnum = {
|
|
1195
1241
|
srt: "srt",
|
|
@@ -2492,9 +2538,6 @@ var createTranscript = (transcriptParams, options) => {
|
|
|
2492
2538
|
var getTranscript = (transcriptId, options) => {
|
|
2493
2539
|
return import_axios2.default.get(`/v2/transcript/${transcriptId}`, options);
|
|
2494
2540
|
};
|
|
2495
|
-
var createTemporaryToken = (createRealtimeTemporaryTokenParams, options) => {
|
|
2496
|
-
return import_axios2.default.post("/v2/realtime/token", createRealtimeTemporaryTokenParams, options);
|
|
2497
|
-
};
|
|
2498
2541
|
|
|
2499
2542
|
// src/adapters/assemblyai-adapter.ts
|
|
2500
2543
|
var AssemblyAIAdapter = class extends BaseAdapter {
|
|
@@ -2514,8 +2557,9 @@ var AssemblyAIAdapter = class extends BaseAdapter {
|
|
|
2514
2557
|
};
|
|
2515
2558
|
this.baseUrl = "https://api.assemblyai.com";
|
|
2516
2559
|
// Generated functions already include /v2 path
|
|
2517
|
-
this.wsBaseUrl = "wss://
|
|
2560
|
+
this.wsBaseUrl = "wss://streaming.assemblyai.com/v3/ws";
|
|
2518
2561
|
}
|
|
2562
|
+
// v3 Universal Streaming endpoint
|
|
2519
2563
|
/**
|
|
2520
2564
|
* Get axios config for generated API client functions
|
|
2521
2565
|
* Configures headers and base URL using authorization header
|
|
@@ -2839,14 +2883,17 @@ var AssemblyAIAdapter = class extends BaseAdapter {
|
|
|
2839
2883
|
*/
|
|
2840
2884
|
async transcribeStream(options, callbacks) {
|
|
2841
2885
|
this.validateConfig();
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
const
|
|
2848
|
-
const
|
|
2849
|
-
|
|
2886
|
+
if (!this.config?.apiKey) {
|
|
2887
|
+
throw new Error("API key is required for streaming");
|
|
2888
|
+
}
|
|
2889
|
+
const sampleRate = options?.sampleRate || 16e3;
|
|
2890
|
+
const encoding = options?.encoding || "pcm_s16le";
|
|
2891
|
+
const wsUrl = `${this.wsBaseUrl}?sample_rate=${sampleRate}&encoding=${encoding}`;
|
|
2892
|
+
const ws = new import_ws2.default(wsUrl, {
|
|
2893
|
+
headers: {
|
|
2894
|
+
Authorization: this.config.apiKey
|
|
2895
|
+
}
|
|
2896
|
+
});
|
|
2850
2897
|
let sessionStatus = "connecting";
|
|
2851
2898
|
const sessionId = `assemblyai-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
2852
2899
|
ws.on("open", () => {
|
|
@@ -2856,41 +2903,42 @@ var AssemblyAIAdapter = class extends BaseAdapter {
|
|
|
2856
2903
|
ws.on("message", (data) => {
|
|
2857
2904
|
try {
|
|
2858
2905
|
const message = JSON.parse(data.toString());
|
|
2859
|
-
if (
|
|
2906
|
+
if ("error" in message) {
|
|
2907
|
+
callbacks?.onError?.({
|
|
2908
|
+
code: "API_ERROR",
|
|
2909
|
+
message: message.error
|
|
2910
|
+
});
|
|
2911
|
+
return;
|
|
2912
|
+
}
|
|
2913
|
+
if (message.type === "Begin") {
|
|
2914
|
+
const beginMsg = message;
|
|
2860
2915
|
callbacks?.onMetadata?.({
|
|
2861
|
-
sessionId:
|
|
2862
|
-
expiresAt:
|
|
2916
|
+
sessionId: beginMsg.id,
|
|
2917
|
+
expiresAt: new Date(beginMsg.expires_at).toISOString()
|
|
2863
2918
|
});
|
|
2864
|
-
} else if (message.
|
|
2919
|
+
} else if (message.type === "Turn") {
|
|
2920
|
+
const turnMsg = message;
|
|
2865
2921
|
callbacks?.onTranscript?.({
|
|
2866
2922
|
type: "transcript",
|
|
2867
|
-
text:
|
|
2868
|
-
isFinal:
|
|
2869
|
-
confidence:
|
|
2870
|
-
words:
|
|
2923
|
+
text: turnMsg.transcript,
|
|
2924
|
+
isFinal: turnMsg.end_of_turn,
|
|
2925
|
+
confidence: turnMsg.end_of_turn_confidence,
|
|
2926
|
+
words: turnMsg.words.map((word) => ({
|
|
2871
2927
|
text: word.text,
|
|
2872
2928
|
start: word.start / 1e3,
|
|
2929
|
+
// Convert ms to seconds
|
|
2873
2930
|
end: word.end / 1e3,
|
|
2874
2931
|
confidence: word.confidence
|
|
2875
2932
|
})),
|
|
2876
|
-
data:
|
|
2933
|
+
data: turnMsg
|
|
2877
2934
|
});
|
|
2878
|
-
} else if (message.
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
words: message.words.map((word) => ({
|
|
2885
|
-
text: word.text,
|
|
2886
|
-
start: word.start / 1e3,
|
|
2887
|
-
end: word.end / 1e3,
|
|
2888
|
-
confidence: word.confidence
|
|
2889
|
-
})),
|
|
2890
|
-
data: message
|
|
2935
|
+
} else if (message.type === "Termination") {
|
|
2936
|
+
const termMsg = message;
|
|
2937
|
+
callbacks?.onMetadata?.({
|
|
2938
|
+
terminated: true,
|
|
2939
|
+
audioDurationSeconds: termMsg.audio_duration_seconds,
|
|
2940
|
+
sessionDurationSeconds: termMsg.session_duration_seconds
|
|
2891
2941
|
});
|
|
2892
|
-
} else if (message.message_type === "SessionTerminated") {
|
|
2893
|
-
callbacks?.onMetadata?.({ terminated: true });
|
|
2894
2942
|
}
|
|
2895
2943
|
} catch (error) {
|
|
2896
2944
|
callbacks?.onError?.({
|
|
@@ -5130,9 +5178,16 @@ function createWebhookRouter() {
|
|
|
5130
5178
|
GladiaAdapter,
|
|
5131
5179
|
GladiaTypes,
|
|
5132
5180
|
GladiaWebhookHandler,
|
|
5181
|
+
ListenV1EncodingParameter,
|
|
5133
5182
|
OpenAIWhisperAdapter,
|
|
5183
|
+
SpeakV1ContainerParameter,
|
|
5184
|
+
SpeakV1EncodingParameter,
|
|
5185
|
+
SpeakV1SampleRateParameter,
|
|
5134
5186
|
SpeechmaticsAdapter,
|
|
5135
5187
|
SpeechmaticsWebhookHandler,
|
|
5188
|
+
StreamingSupportedBitDepthEnum,
|
|
5189
|
+
StreamingSupportedEncodingEnum,
|
|
5190
|
+
StreamingSupportedSampleRateEnum,
|
|
5136
5191
|
VoiceRouter,
|
|
5137
5192
|
WebhookRouter,
|
|
5138
5193
|
createAssemblyAIAdapter,
|