Multi-provider speech-to-text module supporting OpenAI, Deepgram, Gemini, and ElevenLabs with size limits, timeouts, and abort signals.
// Source: https://github.com/cosmicstack-labs/mercury-agent | License: MIT | Copyright 2026 Cosmic Stack
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Speech to text, with a service the owner already set up in Mercury: the
* OpenAI provider (gpt-4o-mini-transcribe, falling back to whisper-1), or a
* Gemini, Deepgram (nova-3) or ElevenLabs (scribe_v1) key saved for voice
* (Settings → Voice / the Optimus plugin). The voice the owner chose there
* decides which one (see pickSpeechEngine). Used for voice notes from
* channels and for dictation in the apps.
*/
import { readFileSync, statSync } from 'node:fs';
import { basename } from 'node:path';
const MAX_BYTES = 25 * 1024 * 1024;
export interface TranscribeCreds {
apiKey: string;
baseUrl?: string;
}
ex
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key