voice-router-dev 0.1.8 → 0.2.0
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 +9415 -8045
- package/dist/index.d.ts +9415 -8045
- 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/README.md
CHANGED
|
@@ -330,7 +330,7 @@ Provider-specific implementations:
|
|
|
330
330
|
|
|
331
331
|
## TypeScript Support
|
|
332
332
|
|
|
333
|
-
Full type definitions included
|
|
333
|
+
Full type definitions included with **provider-specific type safety**:
|
|
334
334
|
|
|
335
335
|
```typescript
|
|
336
336
|
import type {
|
|
@@ -346,6 +346,108 @@ import type {
|
|
|
346
346
|
} from 'voice-router-dev';
|
|
347
347
|
```
|
|
348
348
|
|
|
349
|
+
### Provider-Specific Type Safety
|
|
350
|
+
|
|
351
|
+
**🎯 New: Type-safe responses with provider discrimination**
|
|
352
|
+
|
|
353
|
+
The SDK now provides full type safety for provider-specific responses:
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
// Generic response - raw field is unknown
|
|
357
|
+
const result: UnifiedTranscriptResponse = await router.transcribe(audio);
|
|
358
|
+
|
|
359
|
+
// Provider-specific response - raw field is properly typed!
|
|
360
|
+
const deepgramResult: UnifiedTranscriptResponse<'deepgram'> = await router.transcribe(audio, {
|
|
361
|
+
provider: 'deepgram'
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// ✅ TypeScript knows raw is ListenV1Response
|
|
365
|
+
const metadata = deepgramResult.raw?.metadata;
|
|
366
|
+
const model = deepgramResult.raw?.results?.channels?.[0]?.alternatives?.[0]?.model;
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
**Provider-specific raw response types:**
|
|
370
|
+
- `gladia` → `PreRecordedResponse`
|
|
371
|
+
- `deepgram` → `ListenV1Response`
|
|
372
|
+
- `openai-whisper` → `CreateTranscription200One`
|
|
373
|
+
- `assemblyai` → `AssemblyAITranscript`
|
|
374
|
+
- `azure-stt` → `AzureTranscription`
|
|
375
|
+
|
|
376
|
+
### Exported Parameter Enums
|
|
377
|
+
|
|
378
|
+
**🎯 New: Direct access to provider parameter enums**
|
|
379
|
+
|
|
380
|
+
Import and use provider-specific enums for type-safe configuration:
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
import {
|
|
384
|
+
// Deepgram enums
|
|
385
|
+
ListenV1EncodingParameter,
|
|
386
|
+
ListenV1ModelParameter,
|
|
387
|
+
SpeakV1EncodingParameter,
|
|
388
|
+
|
|
389
|
+
// Gladia enums
|
|
390
|
+
StreamingSupportedEncodingEnum,
|
|
391
|
+
StreamingSupportedSampleRateEnum,
|
|
392
|
+
|
|
393
|
+
// OpenAI types
|
|
394
|
+
AudioResponseFormat
|
|
395
|
+
} from 'voice-router-dev';
|
|
396
|
+
|
|
397
|
+
// ✅ Type-safe Deepgram encoding
|
|
398
|
+
const session = await router.transcribeStream({
|
|
399
|
+
provider: 'deepgram',
|
|
400
|
+
encoding: ListenV1EncodingParameter.linear16, // Autocomplete works!
|
|
401
|
+
model: ListenV1ModelParameter['nova-2'],
|
|
402
|
+
sampleRate: 16000
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// ✅ Type-safe Gladia encoding
|
|
406
|
+
const gladiaSession = await router.transcribeStream({
|
|
407
|
+
provider: 'gladia',
|
|
408
|
+
encoding: StreamingSupportedEncodingEnum['wav/pcm'],
|
|
409
|
+
sampleRate: StreamingSupportedSampleRateEnum['16000']
|
|
410
|
+
});
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Type-Safe Streaming Options
|
|
414
|
+
|
|
415
|
+
Streaming options are now fully typed based on provider OpenAPI specifications:
|
|
416
|
+
|
|
417
|
+
```typescript
|
|
418
|
+
// Deepgram streaming - all options are type-safe
|
|
419
|
+
const deepgramSession = await router.transcribeStream({
|
|
420
|
+
provider: 'deepgram',
|
|
421
|
+
encoding: 'linear16', // ✅ Only Deepgram encodings
|
|
422
|
+
model: 'nova-3', // ✅ Validated model names
|
|
423
|
+
language: 'en-US', // ✅ BCP-47 language codes
|
|
424
|
+
diarization: true,
|
|
425
|
+
smartFormat: true
|
|
426
|
+
}, callbacks);
|
|
427
|
+
|
|
428
|
+
// Gladia streaming - different options
|
|
429
|
+
const gladiaSession = await router.transcribeStream({
|
|
430
|
+
provider: 'gladia',
|
|
431
|
+
encoding: 'wav/pcm', // ✅ Only Gladia encodings
|
|
432
|
+
sampleRate: 16000, // ✅ Only supported rates
|
|
433
|
+
bitDepth: 16, // ✅ Only supported depths
|
|
434
|
+
languageConfig: { languages: ['en'] }
|
|
435
|
+
}, callbacks);
|
|
436
|
+
|
|
437
|
+
// AssemblyAI streaming - simpler options
|
|
438
|
+
const assemblySession = await router.transcribeStream({
|
|
439
|
+
provider: 'assemblyai',
|
|
440
|
+
sampleRate: 16000, // ✅ Only 8000, 16000, 22050, 44100, 48000
|
|
441
|
+
wordTimestamps: true
|
|
442
|
+
}, callbacks);
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
**Benefits:**
|
|
446
|
+
- ✅ **Full IntelliSense** - Autocomplete for all provider-specific options
|
|
447
|
+
- ✅ **Compile-time Safety** - Invalid options caught before runtime
|
|
448
|
+
- ✅ **Provider Discrimination** - Type system knows which provider you're using
|
|
449
|
+
- ✅ **OpenAPI-Generated** - Types come directly from provider specifications
|
|
450
|
+
|
|
349
451
|
## Requirements
|
|
350
452
|
|
|
351
453
|
- **Node.js**: 20.0.0 or higher
|
|
@@ -354,9 +456,41 @@ import type {
|
|
|
354
456
|
|
|
355
457
|
## Documentation
|
|
356
458
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
-
|
|
459
|
+
### API Reference (Auto-Generated)
|
|
460
|
+
|
|
461
|
+
Comprehensive API documentation is auto-generated with [TypeDoc](https://typedoc.org/) from TypeScript source code:
|
|
462
|
+
|
|
463
|
+
📁 **[docs/generated/](./docs/generated/)** - Complete API reference
|
|
464
|
+
|
|
465
|
+
**Main Documentation Sets**:
|
|
466
|
+
|
|
467
|
+
1. **[router/](./docs/generated/router/)** - Core SDK API
|
|
468
|
+
- `voice-router.md` - VoiceRouter class (main entry point)
|
|
469
|
+
- `types.md` - Unified types (UnifiedTranscriptResponse, StreamingOptions, etc.)
|
|
470
|
+
- `adapters/base-adapter.md` - BaseAdapter interface
|
|
471
|
+
|
|
472
|
+
2. **[webhooks/](./docs/generated/webhooks/)** - Webhook handling
|
|
473
|
+
- `webhook-router.md` - WebhookRouter class (auto-detect providers)
|
|
474
|
+
- `types.md` - Webhook event types
|
|
475
|
+
- `{provider}-webhook.md` - Provider-specific webhook handlers
|
|
476
|
+
|
|
477
|
+
3. **Provider-Specific Adapters**:
|
|
478
|
+
- [gladia/](./docs/generated/gladia/) - Gladia adapter API
|
|
479
|
+
- [deepgram/](./docs/generated/deepgram/) - Deepgram adapter API
|
|
480
|
+
- [assemblyai/](./docs/generated/assemblyai/) - AssemblyAI adapter API
|
|
481
|
+
- [openai/](./docs/generated/openai/) - OpenAI Whisper adapter API
|
|
482
|
+
- [azure/](./docs/generated/azure/) - Azure STT adapter API
|
|
483
|
+
- [speechmatics/](./docs/generated/speechmatics/) - Speechmatics adapter API
|
|
484
|
+
|
|
485
|
+
**Most Important Files**:
|
|
486
|
+
- `docs/generated/router/router/voice-router.md` - Main router class
|
|
487
|
+
- `docs/generated/router/router/types.md` - Core types
|
|
488
|
+
- `docs/generated/webhooks/webhook-router.md` - Webhook handling
|
|
489
|
+
|
|
490
|
+
### Developer Documentation
|
|
491
|
+
|
|
492
|
+
- **[docs/DEVELOPMENT.md](./docs/DEVELOPMENT.md)** - Quick reference for developers
|
|
493
|
+
- **[docs/SDK_GENERATION_WORKFLOW.md](./docs/SDK_GENERATION_WORKFLOW.md)** - Technical workflow
|
|
360
494
|
|
|
361
495
|
## Provider Setup Guides
|
|
362
496
|
|