AbsoluteJS

@absolutejs/voice-azure

@absolutejs/voice-azurev0.0.1-beta.7betaVoice & Media

Azure Speech (Cognitive Services) adapter for @absolutejs/voice — Neural TTS over REST + streaming STT over the WebSocket Unified Speech Protocol

#Installation

BASH
bun add @absolutejs/voice-azure

#Capabilities

Overview

Azure Speech (Cognitive Services) adapter for @absolutejs/voice — Neural TTS over REST plus streaming STT over Azure's WebSocket Unified Speech Protocol.

TTS

For telephony bridges, use a μ-law raw format at 8 kHz:

Bearer-token auth (10-minute Azure auth tokens) is also supported:

Options

Option — Required — Default — Notes

subscriptionKey / token — one of — — — Subscription key sent as Ocp-Apim-Subscription-Key, or short-lived bearer token sent as Authorization.

voice — yes — — — Azure voice name, e.g. en-US-JennyNeural, fr-FR-DeniseNeural.

Show 10 more

region — yes\ — — — Azure region (eastus, westus, francecentral, …). \ Or pass baseUrl directly.

baseUrl — no — https://{region}.tts.speech.microsoft.com — Override for sovereign clouds or Azure private endpoints.

endpointPath — no — /cognitiveservices/v1 — Override if you front the service with a gateway.

outputFormat — no — raw-24khz-16bit-mono-pcm — Must be a raw- format (mp3/wav variants are rejected because they aren't streamable frame-by-frame).

language — no — en-US — Used in the SSML xml:lang attribute.

voiceStyle — no — — — Azure neural style (cheerful, empathetic, customerservice, …).

styleDegree — no — — — Only applied when voiceStyle is set (0..2 typically).

prosody — no — — — { rate, pitch, volume } — strings forwarded to the SSML element.

userAgent — no — @absolutejs/voice-azure — Sent as User-Agent.

fetch — no — globalThis.fetch — Inject for tests; opportunistic HTTP/2 multiplexing is enabled for HTTPS targets.

Notes

Only raw- output formats are supported because the voice runtime needs framed PCM/μ-law/α-law to feed transports without buffering the whole response. If you need MP3/WAV for offline assets, call the Azure REST API directly.

The adapter aborts the in-flight HTTP request on session.close(reason) and refuses further send() calls.

Whitespace-only send() is a no-op (matches the ElevenLabs and Cartesia adapters).

Show 1 more

Bearer tokens expire after 10 minutes by default — refresh externally and pass the new value into a fresh adapter, or stick with subscriptionKey for long-running deployments.

STT

The STT adapter speaks Azure's WebSocket Unified Speech Protocol directly (no Microsoft SDK dependency):

Connects to wss://{region}.stt.speech.microsoft.com/speech/recognition/{mode}/cognitiveservices/v1

Authenticates via Ocp-Apim-Subscription-Key or Authorization: Bearer header.

Show 10 more

Sends a speech.config text frame with system metadata on open, then queues any audio sent before the socket finished opening.

Prepends a 44-byte RIFF/WAV header to the first audio chunk (using the format declared in STTAdapterOpenOptions.format) and ships subsequent chunks as raw PCM under the same audio/x-wav content type.

Maps speech.hypothesis → partial events, speech.phrase → final events (RecognitionStatus === "Success" only, with NBest[0].Confidence lifted onto the transcript), and turn.end → endOfTurn with reason: "vendor".

STT options

Option — Required — Default — Notes

subscriptionKey / token — one of — — — Same auth choices as TTS.

region — yes\ — — — Azure region. \ Or pass baseUrl.

baseUrl — no — wss://{region}.stt.speech.microsoft.com — Override for sovereign clouds, private endpoints, or test stubs.

endpointPath — no — /speech/recognition/{mode}/cognitiveservices/v1 — Override if you front the service with a gateway.

recognitionMode — no — conversation — conversation / dictation / interactive.

Outcomes

What you can build

Build on the supported package contract

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

Hardening checklist

Production guidance

Make every external boundary explicitPin the deployed @absolutejs/voice-azure 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-azure example, confirm the supported entry point and version in the API explorer, then inspect the first boundary that did not produce its documented result.

#TTS

Partial snippet

Working example for TTS.

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

const app = voice({
  // ... stt + other voice options ...
  tts: azureTTS({
    region: "eastus",
    subscriptionKey: process.env.AZURE_SPEECH_KEY!,
    voice: "en-US-JennyNeural",
    // optional:
    outputFormat: "raw-24khz-16bit-mono-pcm", // default
    language: "en-US", // default
    voiceStyle: "cheerful",
    styleDegree: 1.5,
    prosody: { rate: "fast", pitch: "+5%" },
  }),
});

#TTS 2

Partial snippet

For telephony bridges, use a μ-law raw format at 8 kHz:

TS
azureTTS({
  region,
  subscriptionKey,
  voice: "en-US-AriaNeural",
  outputFormat: "raw-8khz-8bit-mono-mulaw",
});

#Public entry points

Supported entry points declared by this package manifest.

Package entry point declared in package.json.

@absolutejs/voice-azure@absolutejs/voice-azure/manifest@absolutejs/voice-azure/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.

11 symbols
azureTTSexportPermalinkSource
TS
azureTTS
Exported from @absolutejs/voice-azure