Gradium
Realtime speech-to-text with GradiumSTTService, over Gradium's WebSocket API, with optional server-side turn detection.
Overview
GradiumSTTService: streams audio over a WebSocket to Gradium and pushes interim and final transcriptions. By default the pipeline's VAD closes each utterance by flushing the server. WithenableTurnDetection, Gradium's end-pointing signal decides when turns start and end instead.
Upstream page
Pipecat's documentation for the same service.
Source
packages/gradium/src/stt.ts.
Gradium docs
The speech-to-text WebSocket reference.
Installation
bun add @pipedog/gradiumimport { GradiumSTTService } from "@pipedog/gradium/stt";Prerequisites
- A Gradium account and an API key from Gradium.
- Pass the key as
apiKey. The examples read it fromGRADIUM_API_KEY.
GradiumSTTService
Connects to wss://api.gradium.ai/api/speech/asr, with the key in the x-api-key header.
Configuration
Prop
Type
Settings
Runtime-updatable settings, passed as settings: new GradiumSTTService.Settings({...})
(GradiumSTTSettings). The eot* and postFlushCooldownFrames fields tune turn detection and
are null unless enableTurnDetection is true, which gives them the defaults below.
| Setting | Type | Default | Description |
|---|---|---|---|
language | Language | "any" | Language.EN | English, German, Spanish, French or Portuguese; "any" has Gradium detect it. |
delayInFrames | number | null | 12 (960 ms) | Delay, in 80 ms frames, before text is generated. One of 7, 8, 10, 12, 14, 16, 20, 24, 36, 48. Lower is faster. |
eotHorizonS | number | null | 3.0 | The end-pointing horizon that drives turn decisions. |
eotThreshold | number | null | 0.5 | Inactivity probability at or above which an open turn ends. |
postFlushCooldownFrames | number | null | 8 | Step messages to ignore after a flush before the next turn can start or end. |
Usage
import { Language } from "@pipedog/core/transcriptions/language";
import { GradiumSTTService } from "@pipedog/gradium/stt";
const stt = new GradiumSTTService({
apiKey: process.env.GRADIUM_API_KEY ?? "",
settings: new GradiumSTTService.Settings({ language: Language.EN }),
});With the server's turn detection:
const withTurns = new GradiumSTTService({
apiKey: process.env.GRADIUM_API_KEY ?? "",
enableTurnDetection: true,
settings: new GradiumSTTService.Settings({ eotHorizonS: 3.0, eotThreshold: 0.5 }),
});Event handlers
| Event | Description |
|---|---|
on_connected | The WebSocket connected. |
on_disconnected | The WebSocket closed. |
on_turn_start | The end-pointing signal opened a turn (turn detection on). |
on_turn_end | The end-pointing signal closed the turn (turn detection on). |
Notes
encodingis"pcm"(the sample rate is appended, for examplepcm_16000),"wav"or"opus". Audio at a rate Gradium doesn't accept is resampled.- With
enableTurnDetection, local VAD frames are ignored and the service recommendsExternalUserTurnStrategies, which resolve itsProposedUserStartedSpeakingFrameandProposedUserStoppedSpeakingFrameinto user turns.
| Runtime | Works | What it needs |
|---|---|---|
| Bun | ✅ yes | Nothing. |
| Node.js | ✅ yes | Nothing. |
| Deno | ✅ yes | Nothing. |
| Cloudflare Workers | ✅ yes | Nothing. |
Generated from pipecat.runtimes and pipecat.compat in packages/gradium/package.json: ✅ means the compat smoke test passes on that runtime.
Runtime notes
- The WebSocket goes through the core
websocketConnect, with headers on the handshake. - The deprecated
InputParams,paramsandjson_configoptions are not ported. - Tested against local WebSocket servers, as upstream's tests do, not against Gradium itself.
pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.
Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).