AbsoluteJS

@absolutejs/voice-gladia

@absolutejs/voice-gladiav0.0.1-beta.5betaVoice & Media

Gladia real-time speech-to-text adapter for @absolutejs/voice

#Installation

BASH
bun add @absolutejs/voice-gladia

#Capabilities

Overview

Gladia real-time speech-to-text adapter for @absolutejs/voice.

Implements Gladia's two-step v2 live handshake directly (no Gladia SDK dep): POST /v2/live to create a session and receive a one-time WebSocket URL, connect, stream binary PCM/μ-law/A-law audio, and consume transcript / end_of_utterance JSON messages. Excellent at multilingual code-switch (Hindi-English, Catalan-Spanish, etc.) thanks to Gladia's language model.

Use

For mixed Hindi/English callers (CoSHE-style), pair with languageStrategy:

Options

Option — Required — Default — Notes

apiKey — yes — — — Gladia API key, sent as X-Gladia-Key.

model — no — solaria-1 — Gladia model id.

Show 9 more

languages — no — — — Default language list, overridden when STTAdapterOpenOptions.languageStrategy resolves a list.

codeSwitching — no — — — Enable mid-utterance language switching.

realtimeProcessing — no — — — Forwarded to Gladia's realtime_processing config (sentences, diarization, etc.).

punctuationConfig — no — — — Forwarded to punctuation_config.

baseUrl — no — https://api.gladia.io — Override for staging / enterprise endpoints.

sessionPath — no — /v2/live — Override if you proxy Gladia behind a gateway.

connectTimeoutMs — no — 8000 — Time to wait for the WebSocket open event.

fetch — no — globalThis.fetch — Inject for tests; opportunistic HTTP/2 multiplexing on outbound HTTPS.

webSocket.factory — no — new WebSocket(url) — Inject a fake socket for tests.

Notes

Audio sent before the WebSocket open completes is buffered and flushed once the socket is ready.

transcript messages → partial when data.is_final !== true, final otherwise. Confidence + per-utterance start / end (converted to ms) are lifted onto the transcript.

end_of_utterance / speech_end → endOfTurn with reason: "vendor".

Show 2 more

session.close(reason) sends { "type": "stop_recording" } and then closes the socket cleanly.

Supported encodings on STTAdapterOpenOptions.format.encoding: pcm_s16le → wav/pcm, mulaw / pcm_mulaw → wav/ulaw, alaw / pcm_alaw → wav/alaw.

Outcomes

What you can build

Build on the supported package contract

Use @absolutejs/voice-gladia through its supported public entry points.

Hardening checklist

Production guidance

Make every external boundary explicitPin the deployed @absolutejs/voice-gladia version, replace example or memory-backed dependencies with durable implementations, bound external calls, protect credentials, and emit enough evidence to retry or recover safely.

Follow in order

Troubleshooting path

1
Trace from the first failed boundary
Reproduce the smallest canonical @absolutejs/voice-gladia example, confirm the supported entry point and version in the API explorer, then inspect the first boundary that did not produce its documented result.

#Use

Partial snippet

Working example for Use.

TS
import { voice } from "@absolutejs/voice";
import { gladia } from "@absolutejs/voice-gladia";

const app = voice({
  stt: gladia({
    apiKey: process.env.GLADIA_API_KEY!,
    // optional:
    model: "solaria-1",
    languages: ["en"], // language detection seed
    codeSwitching: true, // for multilingual callers
    realtimeProcessing: { sentences: true },
  }),
  // ... tts + other options ...
});

#Use 2

Partial snippet

For mixed Hindi/English callers (CoSHE-style), pair with languageStrategy:

TS
app.use({
  stt: gladia({ apiKey, codeSwitching: true }),
  // and at open() time:
  // languageStrategy: { mode: 'allow-switching', primaryLanguage: 'en', secondaryLanguages: ['hi'] }
});

#Public entry points

Supported entry points declared by this package manifest.

Package entry point declared in package.json.

@absolutejs/voice-gladia@absolutejs/voice-gladia/manifest@absolutejs/voice-gladia/manifest.json

#Package commands

Scripts declared by this package manifest.

bun run buildrm -rf dist && bun build ./src/index.ts ./src/manifest.ts --outdir dist --target bun --external @absolutejs/manifest --external '@absolutejs/manifest/*' --external @absolutejs/voice --external '@absolutejs/voice/*' --external @sinclair/typebox --external '@sinclair/typebox/*' && tsc --emitDeclarationOnly --project tsconfig.json && absolute-manifest emit
bun run check:packagebun run format && bun run typecheck && bun run test && bun run verify-package && bun run build && bun run verify-package --artifacts
bun run formatprettier --write "./**/*.{js,ts,json,md}"
bun run testbun test
bun run typecheckbun run tsc --noEmit

#API reference

Search the declarations exported by the current package type files. Expand a symbol to inspect its source-backed signature.

5 symbols
gladiaexportPermalinkSource
TS
gladia
Exported from @absolutejs/voice-gladia