@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
116 lines (115 loc) • 3.84 kB
TypeScript
/**
* Speech-to-Text (STT) Processing Utility
*
* Central orchestrator for all STT operations across providers.
* Manages provider-specific STT handlers and audio transcription.
*
* @module utils/sttProcessor
*/
import type { STTOptions, STTResult, STTHandler } from "../types/index.js";
/**
* STT processor class for orchestrating speech-to-text operations
*
* Follows the same pattern as TTSProcessor, CSVProcessor, ImageProcessor, and PDFProcessor.
* Provides a unified interface for STT transcription across multiple providers.
*
* @example
* ```typescript
* // Register a handler
* STTProcessor.registerHandler('whisper', whisperHandler);
*
* // Check if provider is supported
* if (STTProcessor.supports('whisper')) {
* // Provider is registered
* }
* ```
*/
export declare class STTProcessor {
/**
* Handler registry mapping provider names to STT handlers
* Uses Map for O(1) lookups and better type safety
*
* @private
*/
private static readonly handlers;
/**
* Default maximum audio duration for STT transcription (in seconds)
*
* Providers can override this value by specifying the `maxAudioDuration` property
* in their respective `STTHandler` implementation. If not specified, this default
* value will be used (5 minutes).
*
* @private
*/
private static readonly DEFAULT_MAX_AUDIO_DURATION;
/**
* Register an STT handler for a specific provider
*
* Allows providers to register their STT implementation at runtime.
*
* @param providerName - Provider identifier (e.g., 'whisper', 'deepgram')
* @param handler - STT handler implementation
*
* @example
* ```typescript
* const whisperHandler: STTHandler = {
* transcribe: async (audio, options) => { ... },
* getSupportedFormats: () => ["mp3", "wav"],
* isConfigured: () => true
* };
*
* STTProcessor.registerHandler('whisper', whisperHandler);
* ```
*/
static registerHandler(providerName: string, handler: STTHandler): void;
/**
* Get a registered STT handler by provider name
*
* @private
* @param providerName - Provider identifier
* @returns Handler instance or undefined if not registered
*/
private static getHandler;
/**
* Check if a provider is supported (has a registered STT handler)
*
* @param providerName - Provider identifier
* @returns True if handler is registered
*
* @example
* ```typescript
* if (STTProcessor.supports('whisper')) {
* console.log('Whisper STT is supported');
* }
* ```
*/
static supports(providerName: string): boolean;
/**
* Transcribe audio to text using a registered STT provider
*
* Orchestrates the speech-to-text transcription process:
* 1. Validates audio input (non-empty)
* 2. Looks up the provider handler
* 3. Verifies provider configuration
* 4. Delegates transcription to the provider
* 5. Enriches result with provider metadata
*
* @param audio - Audio data as Buffer or ArrayBuffer
* @param provider - Provider identifier
* @param options - STT configuration options
* @returns Transcription result with text and metadata
* @throws STTError if validation fails or provider not supported/configured
*
* @example
* ```typescript
* const result = await STTProcessor.transcribe(audioBuffer, "whisper", {
* language: "en-US",
* punctuation: true,
* });
*
* console.log(`Transcription: ${result.text}`);
* console.log(`Confidence: ${result.confidence}`);
* ```
*/
static transcribe(audio: Buffer | ArrayBuffer, provider: string, options: STTOptions): Promise<STTResult>;
}