UNPKG

@volley/recognition-client-sdk

Version:

Recognition Service TypeScript/Node.js Client SDK

129 lines 3.51 kB
/** * Configuration Builder for Recognition Client * * Simple builder pattern for RealTimeTwoWayWebSocketRecognitionClientConfig */ import type { RealTimeTwoWayWebSocketRecognitionClientConfig, RecognitionCallbackUrl } from './recognition-client.types.js'; import type { ASRRequestConfig, GameContextV1, TranscriptionResultV1, MetadataResultV1, ErrorResultV1, Stage } from '@recog/shared-types'; /** * Builder for RealTimeTwoWayWebSocketRecognitionClientConfig * * Provides a fluent API for building client configurations. * * Example: * ```typescript * import { STAGES } from '@recog/shared-types'; * * const config = new ConfigBuilder() * .stage(STAGES.STAGING) // Recommended: automatic environment selection * .asrRequestConfig({ * provider: RecognitionProvider.DEEPGRAM, * model: 'nova-2-general' * }) * .onTranscript((result) => console.log(result)) * .build(); * ``` */ export declare class ConfigBuilder { private config; /** * Set the WebSocket URL (advanced usage) * For standard environments, use stage() instead */ url(url: string): this; /** * Set the stage for automatic environment selection (recommended) * @param stage - STAGES.LOCAL | STAGES.DEV | STAGES.STAGING | STAGES.PRODUCTION * @example * ```typescript * import { STAGES } from '@recog/shared-types'; * builder.stage(STAGES.STAGING) * ``` */ stage(stage: Stage | string): this; /** * Set ASR request configuration */ asrRequestConfig(config: ASRRequestConfig): this; /** * Set game context */ gameContext(context: GameContextV1): this; /** * Set audio utterance ID */ audioUtteranceId(id: string): this; /** * Set callback URLs */ callbackUrls(urls: RecognitionCallbackUrl[]): this; /** * Set user ID */ userId(id: string): this; /** * Set game session ID */ gameSessionId(id: string): this; /** * Set device ID */ deviceId(id: string): this; /** * Set account ID */ accountId(id: string): this; /** * Set question answer ID */ questionAnswerId(id: string): this; /** * Set platform */ platform(platform: string): this; /** * Set transcript callback */ onTranscript(callback: (result: TranscriptionResultV1) => void): this; /** * Set metadata callback */ onMetadata(callback: (metadata: MetadataResultV1) => void): this; /** * Set error callback */ onError(callback: (error: ErrorResultV1) => void): this; /** * Set connected callback */ onConnected(callback: () => void): this; /** * Set disconnected callback */ onDisconnected(callback: (code: number, reason: string) => void): this; /** * Set high water mark */ highWaterMark(bytes: number): this; /** * Set low water mark */ lowWaterMark(bytes: number): this; /** * Set max buffer duration in seconds */ maxBufferDurationSec(seconds: number): this; /** * Set chunks per second */ chunksPerSecond(chunks: number): this; /** * Set logger function */ logger(logger: (level: 'debug' | 'info' | 'warn' | 'error', message: string, data?: any) => void): this; /** * Build the configuration */ build(): RealTimeTwoWayWebSocketRecognitionClientConfig; } //# sourceMappingURL=config-builder.d.ts.map