voice-router-dev 0.1.5 → 0.1.7
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.d.mts +370 -202
- package/dist/index.d.ts +370 -202
- package/dist/index.js +14 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -202,39 +202,7 @@ var VoiceRouter = class {
|
|
|
202
202
|
const adapter = this.getAdapter(provider);
|
|
203
203
|
return adapter.getTranscript(transcriptId);
|
|
204
204
|
}
|
|
205
|
-
|
|
206
|
-
* Stream audio for real-time transcription
|
|
207
|
-
* Only works with providers that support streaming
|
|
208
|
-
*
|
|
209
|
-
* @param options - Streaming options including provider selection
|
|
210
|
-
* @param callbacks - Event callbacks for transcription results
|
|
211
|
-
* @returns Promise that resolves with a StreamingSession
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* import { VoiceRouter } from '@meeting-baas/sdk';
|
|
216
|
-
*
|
|
217
|
-
* const router = new VoiceRouter();
|
|
218
|
-
* router.initialize({
|
|
219
|
-
* gladia: { apiKey: process.env.GLADIA_KEY },
|
|
220
|
-
* deepgram: { apiKey: process.env.DEEPGRAM_KEY }
|
|
221
|
-
* });
|
|
222
|
-
*
|
|
223
|
-
* const session = await router.transcribeStream({
|
|
224
|
-
* provider: 'deepgram',
|
|
225
|
-
* encoding: 'linear16',
|
|
226
|
-
* sampleRate: 16000,
|
|
227
|
-
* language: 'en'
|
|
228
|
-
* }, {
|
|
229
|
-
* onTranscript: (event) => console.log(event.text),
|
|
230
|
-
* onError: (error) => console.error(error)
|
|
231
|
-
* });
|
|
232
|
-
*
|
|
233
|
-
* // Send audio chunks
|
|
234
|
-
* await session.sendAudio({ data: audioBuffer });
|
|
235
|
-
* await session.close();
|
|
236
|
-
* ```
|
|
237
|
-
*/
|
|
205
|
+
// Implementation
|
|
238
206
|
async transcribeStream(options, callbacks) {
|
|
239
207
|
const provider = this.selectProvider(options?.provider);
|
|
240
208
|
const adapter = this.getAdapter(provider);
|
|
@@ -1873,11 +1841,20 @@ var GladiaAdapter = class extends BaseAdapter {
|
|
|
1873
1841
|
*/
|
|
1874
1842
|
async transcribeStream(options, callbacks) {
|
|
1875
1843
|
this.validateConfig();
|
|
1844
|
+
let validatedSampleRate;
|
|
1845
|
+
if (options?.sampleRate) {
|
|
1846
|
+
const validRates = Object.values(StreamingSupportedSampleRateEnum);
|
|
1847
|
+
const isValidRate = validRates.some((rate) => rate === options.sampleRate);
|
|
1848
|
+
if (!isValidRate) {
|
|
1849
|
+
throw new Error(
|
|
1850
|
+
`Gladia does not support sample rate ${options.sampleRate} Hz. Supported rates (from OpenAPI spec): ${validRates.join(", ")} Hz`
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1853
|
+
validatedSampleRate = options.sampleRate;
|
|
1854
|
+
}
|
|
1876
1855
|
const streamingRequest = {
|
|
1877
|
-
// Map unified encoding format to Gladia's provider-specific format
|
|
1878
|
-
// e.g., 'linear16' → 'wav/pcm'
|
|
1879
1856
|
encoding: options?.encoding ? mapEncodingToProvider(options.encoding, "gladia") : void 0,
|
|
1880
|
-
sample_rate:
|
|
1857
|
+
sample_rate: validatedSampleRate,
|
|
1881
1858
|
channels: options?.channels,
|
|
1882
1859
|
endpointing: options?.endpointing
|
|
1883
1860
|
};
|
|
@@ -3042,7 +3019,7 @@ var DeepgramAdapter = class extends BaseAdapter {
|
|
|
3042
3019
|
params.detect_entities = true;
|
|
3043
3020
|
}
|
|
3044
3021
|
if (options.piiRedaction) {
|
|
3045
|
-
params.redact =
|
|
3022
|
+
params.redact = ["pci", "pii"];
|
|
3046
3023
|
}
|
|
3047
3024
|
if (options.webhookUrl) {
|
|
3048
3025
|
params.callback = options.webhookUrl;
|