🎤Micdrop

Gemini Transcribe Speech to Text in Node.js

GeminiSTT streams the voice of the user to Gemini Transcribe over the Live API, and emits the transcript of each utterance a fraction of a second after it ends.

Installation

Terminal window
npm install @micdrop/gemini

The same package also provides an agent, a text to speech, Gemini Live and a classifier. The providers page shows what every provider covers.

Usage with MicdropServer

import { GeminiSTT } from '@micdrop/gemini'
import { MicdropServer } from '@micdrop/server'
const stt = new GeminiSTT({
apiKey: process.env.GEMINI_API_KEY || '',
language: 'en-US', // Optional, detected when left out
vocabulary: ['Micdrop'], // Optional, words to recognize
})
new MicdropServer(socket, {
stt,
// ... other options
})

Usage without MicdropServer

import { GeminiSTT } from '@micdrop/gemini'
import { createReadStream } from 'fs'
const stt = new GeminiSTT({ apiKey: process.env.GEMINI_API_KEY || '' })
stt.on('Transcript', (transcript) => console.log('Transcript:', transcript))
// Audio is raw PCM, 16 bits, 16 kHz, mono
stt.transcribe(createReadStream('speech.pcm'))

Events

EventPayloadDescription
TranscriptstringThe transcript of an utterance, empty when nothing was understood.
FailedBuffer[]The connection could not be restored, with the audio still untranscribed.

See the STT interface for the full contract.

Each stream given to transcribe() is one utterance with a transcript of its own, and the transcripts come in the order of the streams. A stream can start while the previous one still waits for its transcript: Gemini names no utterance in what it sends, so it hears them one after the other, and the audio of the next one waits for the transcript of the previous.

Options

OptionTypeDefaultDescription
apiKeystringRequiredYour Gemini API key
modelstring'gemini-3.5-transcribe-live'Transcription model
languagestringundefinedLanguage of the user, as a BCP-47 code like fr-FR
vocabularystring[]undefinedWords to recognize, up to 1,000
mode'SMART' | 'VERBATIM'Model defaultCleans up hesitations, or keeps every word as said
transcriptionTimeoutnumber4000How long to wait for a transcript, in milliseconds
connectionTimeoutnumber5000Time to open the connection, in milliseconds
retryDelaynumber1000Delay before reconnecting, in milliseconds
maxRetrynumber3Reconnection attempts before giving up