UNPKG

@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

61 lines (60 loc) • 2.18 kB
/** * Google Cloud Speech-to-Text Handler * * Implementation of STT using Google Cloud Speech-to-Text API. * * @module voice/providers/GoogleSTT */ import type { TTSAudioFormat, STTHandler, STTLanguage, STTOptions, STTResult, TranscriptionSegment } from "../../types/index.js"; /** * Google Cloud Speech-to-Text Handler * * Supports transcription with speaker diarization, word timestamps, and punctuation. * * @see https://cloud.google.com/speech-to-text/docs */ export declare class GoogleSTT implements STTHandler { private readonly apiKey; private readonly credentialsPath; private readonly baseUrl; /** * Maximum audio duration in seconds for the synchronous recognize endpoint. * For longer audio, use the async longrunningrecognize endpoint (not yet implemented). */ readonly maxAudioDuration = 60; /** * True streaming requires gRPC (not yet implemented). * transcribeStream() uses a chunk-and-batch workaround. */ readonly supportsStreaming = false; constructor(apiKey?: string, credentialsPath?: string); isConfigured(): boolean; getSupportedFormats(): TTSAudioFormat[]; getSupportedLanguages(): Promise<STTLanguage[]>; transcribe(audio: Buffer | ArrayBuffer, options?: STTOptions): Promise<STTResult>; /** * Streaming transcription (placeholder - requires WebSocket/gRPC) */ transcribeStream(audioStream: AsyncIterable<Buffer>, options: STTOptions): AsyncIterable<TranscriptionSegment>; /** * Get encoding string for audio format */ private getEncoding; /** * Parse duration string (e.g., "1.5s") to seconds */ private parseDuration; /** * Calculate average confidence from results */ private calculateAverageConfidence; /** * Get access token from service account credentials. * * M3: previously caught all errors and returned `""`, which then caused * a silent 401 from the Google API and a confusing downstream HTTP error * with no trace of the original auth failure. Now rethrows as STTError so * the caller sees the auth root cause. */ private getAccessToken; }