@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
74 lines (73 loc) • 4.82 kB
TypeScript
/**
* Voice Module - Unified Voice/Speech Integration for NeuroLink
*
* Provides TTS (Text-to-Speech), STT (Speech-to-Text), and
* Realtime Voice capabilities across multiple providers.
*
* Use TTSProcessor (src/lib/utils/ttsProcessor.ts) for TTS.
* Use STTProcessor (src/lib/utils/sttProcessor.ts) for STT.
* Use RealtimeProcessor for realtime voice sessions.
*
* Importing this module does NOT register any handlers as a side effect.
* Call `registerDefaultTTSHandlers()` / `registerDefaultSTTHandlers()` /
* `registerDefaultRealtimeHandlers()` explicitly (or go through
* `ProviderRegistry.registerAllProviders()`, which every documented
* `NeuroLink` entry point already calls) to register every shipped handler
* whose backing API key is present in `process.env`. Registration is
* idempotent and silently skipped on failure.
*
* @module voice
*/
import type { STTCredentials, STTHandler } from "../types/index.js";
export { AUDIO_FORMAT_DETAILS, DEFAULT_REALTIME_CONFIG, DEFAULT_STT_OPTIONS, isSTTResult, isTranscriptionSegment, isValidRealtimeConfig, isValidSTTOptions, REALTIME_ERROR_CODES, STT_ERROR_CODES, VOICE_ERROR_CODES, } from "../types/index.js";
export { RealtimeError, STTError, VoiceError } from "./errors.js";
export { BaseRealtimeHandler, RealtimeProcessor } from "./RealtimeVoiceAPI.js";
export { AUDIO_SIGNATURES, calculateDuration, convertAudioFormat, createPcmBuffer, createWavFile, createWavHeader, detectAudioFormat, extractPcmSamples, getFileExtension, getMimeType, MIME_TYPES, normalizeAudio, resamplePcm, splitIntoChunks, } from "./audio-utils.js";
export { asyncIterableToStream, ChunkedAudioStream, StreamHandler, StreamMerger, StreamSplitter, streamToAsyncIterable, } from "./stream-handler.js";
export { GoogleTTSHandler } from "../adapters/tts/googleTTSHandler.js";
export { AzureTTS, AzureTTS as AzureTTSHandler } from "./providers/AzureTTS.js";
export { SixtyDBTTS, SixtyDBTTS as SixtyDBTTSHandler, } from "./providers/SixtyDBTTS.js";
export { CartesiaTTS, CartesiaTTS as CartesiaTTSHandler, } from "./providers/CartesiaTTS.js";
export { ElevenLabsTTS, ElevenLabsTTS as ElevenLabsTTSHandler, } from "./providers/ElevenLabsTTS.js";
export { FishAudioTTS, FishAudioTTS as FishAudioTTSHandler, } from "./providers/FishAudioTTS.js";
export { OpenAITTS, OpenAITTS as OpenAITTSHandler, } from "./providers/OpenAITTS.js";
export { AzureSTT, AzureSTT as AzureSTTHandler } from "./providers/AzureSTT.js";
export { DeepgramSTT, DeepgramSTT as DeepgramSTTHandler, } from "./providers/DeepgramSTT.js";
export { ElevenLabsSTT, ElevenLabsSTT as ElevenLabsSTTHandler, } from "./providers/ElevenLabsSTT.js";
export { GoogleSTT, GoogleSTT as GoogleSTTHandler, } from "./providers/GoogleSTT.js";
export { OpenAISTT, OpenAISTTHandler, WhisperSTT, WhisperSTTHandler, } from "./providers/OpenAISTT.js";
export { WhistleSTT, WhistleSTT as WhistleSTTHandler, } from "./providers/WhistleSTT.js";
export { GeminiLive, GeminiLive as GeminiLiveHandler, } from "./providers/GeminiLive.js";
export { OpenAIRealtime, OpenAIRealtime as OpenAIRealtimeHandler, } from "./providers/OpenAIRealtime.js";
/**
* A fresh STT handler for a shipped provider name or alias, built from
* `credentials` with the environment as fallback. Used for per-call
* credentials, where the registry's shared instance (built from the
* environment at registration time) is the wrong one.
*
* @throws STTError when the name is not a shipped STT provider
*/
export declare function createSTTHandler(provider: string, credentials?: STTCredentials): STTHandler;
/**
* Register every shipped TTS handler whose backing credentials are
* present in the environment. Safe to call multiple times.
*/
export declare function registerDefaultTTSHandlers(): void;
/**
* Register every shipped STT handler whose backing credentials are present in
* the ENVIRONMENT, plus the built-in local engine (Whistle), which is always
* registered because it is what a transcription with nothing configured falls
* back to, plus the env-declared named endpoints (`NEUROLINK_STT_ENDPOINTS`).
* Safe to call multiple times; a name that is already registered is left
* alone. Deliberately takes no credentials: the registry is process-wide, so
* a handler built from one caller's keys or base URL would be served to every
* later caller — per-call and per-instance credentials are resolved at call
* time by `STTProcessor.resolveHandler` / `createSTTHandler` instead.
*/
export declare function registerDefaultSTTHandlers(): void;
/**
* Register every shipped Realtime handler. Realtime handlers don't gate
* registration on isConfigured() because session-time API keys can be
* supplied per-call; missing creds surface when `connect()` is invoked.
*/
export declare function registerDefaultRealtimeHandlers(): void;