Skip to main content

GoogleSTT

Google Cloud speech-to-text (STT) provider.

Constructor

apiKey
string | null
Google API key. Falls back to the GOOGLE_API_KEY environment variable, then null.
languages
string | string[]
Recognition language(s) as BCP-47 tags (e.g. 'en-US'), a single string or an array (joined with commas). Default 'en-US'.
model
GoogleSTTModel | string
Recognition model. Default 'latest_long'.
sampleRate
number
Input audio sample rate in Hz. Default 48000.
credentialsJson
string | Record<string, any> | null
Service-account credentials, as a raw JSON string or parsed object. Default null.
serviceAccountPath
string | null
Path to a service-account JSON key file. Read when credentialsJson is not provided.
projectId
string | null
Google Cloud project id. Default null (derived from the service-account JSON when omitted).
location
string
Recognizer location/region. Default 'us'.
stream
boolean
Use streaming recognition. Default true.
audioChannelCount
number
Number of audio channels in the input. Default 1.
interimResults
boolean
Emit interim (non-final) transcription results. Default true.
punctuate
boolean
Add automatic punctuation to transcripts. Default true.
profanityFilter
boolean
Filter profanity from transcripts. Default false.
enableSpokenPunctuation
boolean
Recognize spoken punctuation (e.g. “comma” -> ”,”). Default false.
enableSpokenEmojis
boolean
Recognize spoken emojis. Default false.
enableWordTimeOffsets
boolean
Include per-word start/end time offsets. Default false.
enableWordConfidence
boolean
Include per-word confidence scores. Default false.
maxAlternatives
number
Maximum number of recognition alternatives to return. Default 1.
enableVoiceActivityEvents
boolean
Emit voice-activity (speech begin/end) events. Default false.
speechStartTimeout
number | null
Timeout in seconds to wait for speech to start. Default null (no timeout).
speechEndTimeout
number | null
Timeout in seconds of silence marking speech end. Default null (no timeout).
minSpeakerCount
number | null
Minimum number of speakers for diarization. Default null.
maxSpeakerCount
number | null
Maximum number of speakers for diarization. Default null.
minConfidenceThreshold
number
Minimum confidence threshold for accepting results, 0.0-1.0. Default 0.0.

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getRuntimeConfig

returns
Record<string, any>

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

onSttTranscript

Register a callback to receive transcripts as they are produced.
callback
SttTranscriptCallback
required

processAudio

Process a buffer of audio frames. Override in a custom provider.

removeAllListeners

event
string

streamTranscribe

Transcribe a streaming audio source, yielding STTResponses. Override in a custom provider.
returns
AsyncIterator<STTResponse>

GoogleSTTModel

Supported Google Cloud STT recognition model ids.