buildTranscriptionRequest (models/transcription.ts)

cloudflare/agents · packages/agents/src/models/ai-sdk/models/transcription.ts · typescript · MIT
voice

Helper to build transcription requests for Cloudflare AI models like Whisper and Deepgram.

// Source: https://github.com/cloudflare/agents | License: MIT
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Speech recognition over the Cloudflare run path.
 *
 * `whisper-large-v3-turbo` takes the audio as base64 (`{ audio: "<base64>" }`,
 * verified live); the two older whisper ids take it as an unsigned-byte array.
 * Deepgram's Nova-3 takes it as a raw body (`audio: { body, contentType }`),
 * which the transport sends as one, its other fields alongside. Flux takes
 * websocket connections only, so it is refused with a clear error.
 */

import type {
  JSONObject,
  SharedV4Warning,
  TranscriptionModelV4,
  TranscriptionModelV4CallOptions,
  TranscriptionModelV4Result
} from "@ai-sdk/provider";
import { CloudflareAIError } from "../errors";
import { PROVIDER

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

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

Get a free API key