DeepgramSTT (deepgram/index.js)

anything-llm · server/utils/SpeechToText/deepgram/index.js · javascript · MIT
voice

DeepgramSTT provides a wrapper for Deepgram speech-to-text transcription.

// Source: https://github.com/Mintplex-Labs/anything-llm | License: MIT | Copyright Mintplex Labs Inc
// Provided via justclaw.it.com; keep this notice with the code.
class DeepgramSTT {
  constructor() {
    if (!process.env.STT_DEEPGRAM_API_KEY)
      throw new Error("No Deepgram API key was set.");

    this.apiKey = process.env.STT_DEEPGRAM_API_KEY;
    this.model = process.env.STT_DEEPGRAM_MODEL ?? "nova-3";
    this.endpoint = "https://api.deepgram.com/v1/listen";
    this.#log(`Service ready with model: ${this.model}`);
  }

  #log(text, ...args) {
    console.log(`\x1b[32m[DeepgramSTT]\x1b[0m ${text}`, ...args);
  }

  // Map common audio file extensions to a Content-Type that Deepgram accepts.
  // Deepgram auto-detects most containers from the bytes but a hint is best.
  #content

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key