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

63 lines (62 loc) • 2.35 kB
/** * Google Cloud Speech-to-Text Handler * * Implementation of STT using Google Cloud Speech-to-Text API. * * @module voice/providers/GoogleSTT */ import type { TTSAudioFormat, STTCredentials, STTHandler, STTLanguage, STTOptions, STTResult } 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 implemented). `transcribeStream()` on * the SDK streams this handler through the generic chunked adapter. */ readonly supportsStreaming = false; /** * @param apiKeyOrCredentials - The `credentials.stt.google` slice * (`apiKey`, `credentialsPath`), or an API key (the original positional * form). The environment fills whatever is left out. * @param credentialsPath - Service-account file, positional form only. */ constructor(apiKeyOrCredentials?: string | STTCredentials["google"], credentialsPath?: string); isConfigured(): boolean; getSupportedFormats(): TTSAudioFormat[]; getSupportedLanguages(): Promise<STTLanguage[]>; transcribe(audio: Buffer | ArrayBuffer, options?: STTOptions): Promise<STTResult>; /** * 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; }