Azure AI Voicelive TS
MicrosoftOfficialCreated by Microsoft
- Skill
- Tool integration
- Data and AI
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The Azure AI Voice Live SDK for JavaScript and TypeScript enables developers to create voice-enabled applications that support real-time, bidirectional communication. It provides a client-based interface for managing WebSocket sessions, handling audio streaming, and integrating function calling capabilities within Node.js or browser-based environments.
What it does
- Establishes bidirectional WebSocket sessions for voice interaction.
- Supports streaming audio input and output in various formats.
- Provides event-based subscription patterns for handling conversation lifecycle.
- Enables function calling to allow AI assistants to execute external actions.
- Supports multiple voice configuration options and turn detection settings.
- Facilitates integration with Azure identity services for authentication.
When to use it
- When building conversational voice assistants in TypeScript or JavaScript.
- When implementing real-time speech-to-speech features.
- When integrating voice-enabled chatbots into web or server-side applications.
- When you need to define custom tools for an AI assistant to perform tasks.
Advantages
- Provides a structured client hierarchy for session management.
- Supports both Node.js and modern browser environments.
- Includes built-in support for function calling and tool definitions.
- Offers flexible audio format and turn detection configuration.
- Uses standard Azure SDK authentication patterns.
Usage examples
- “How do I start a voice session with the SDK?”
- Initialize a VoiceLiveClient with credentials, then call client.startSession() with the desired model name to establish a WebSocket connection.
- “How can I add a custom tool to my voice assistant?”
- Define the tool using JSON Schema in the session configuration's tools array, then handle the onResponseFunctionCallArgumentsDone event to execute your function logic.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/microsoft/azure-ai-voicelive-ts/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip azure-ai-voicelive-ts.zip -d .agents/skills
Documentation by Microsoft
@azure/ai-voicelive (JavaScript/TypeScript)
Real-time voice AI SDK for building bidirectional voice assistants with Azure AI in Node.js and browser environments.
Installation
npm install @azure/ai-voicelive @azure/identity
# TypeScript users
npm install @types/nodeCurrent Version: 1.0.0-beta.3
Supported Environments:
Node.js LTS versions (20+)
Modern browsers (Chrome, Firefox, Safari, Edge)
Environment Variables
AZURE_VOICELIVE_ENDPOINT=https://<resource>.cognitiveservices.azure.com
# Optional: API key if not using Entra ID
AZURE_VOICELIVE_API_KEY=<your-api-key>
# Optional: Logging
AZURE_LOG_LEVEL=info
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in productionAuthentication
Microsoft Entra Token Credential (Recommended)
import { DefaultAzureCredential, ManagedIdentityCredential } from "@azure/identity";
import { VoiceLiveClient } from "@azure/ai-voicelive";
// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
const credential = new DefaultAzureCredential({requiredEnvVars: ["AZURE_TOKEN_CREDENTIALS"]});
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/javascript/api/overview/azure/identity-readme?view=azure-node-latest#credential-classes
// const credential = new ManagedIdentityCredential();
const endpoint = "https://your-resource.cognitiveservices.azure.com";
const client = new VoiceLiveClient(endpoint, credential);API Key
import { AzureKeyCredential } from "@azure/core-auth";
import { VoiceLiveClient } from "@azure/ai-voicelive";
const endpoint = "https://your-resource.cognitiveservices.azure.com";
const credential = new AzureKeyCredential("your-api-key");
const client = new VoiceLiveClient(endpoint, credential);Client Hierarchy
VoiceLiveClient
└── VoiceLiveSession (WebSocket connection)
├── updateSession() → Configure session options
├── subscribe() → Event handlers (Azure SDK pattern)
├── sendAudio() → Stream audio input
├── addConversationItem() → Add messages/function outputs
└── sendEvent() → Send raw protocol eventsQuick Start
import { DefaultAzureCredential } from "@azure/identity";
import { VoiceLiveClient } from "@azure/ai-voicelive";
const credential = new DefaultAzureCredential({requiredEnvVars: ["AZURE_TOKEN_CREDENTIALS"]});
const endpoint = process.env.AZURE_VOICELIVE_ENDPOINT!;
// Create client and start session
const client = new VoiceLiveClient(endpoint, credential);
const session = await client.startSession("gpt-4o-mini-realtime-preview");
// Configure session
await session.updateSession({
modalities: ["text", "audio"],
instructions: "You are a helpful AI assistant. Respond naturally.",
voice: {
type: "azure-standard",
name: "en-US-AvaNeural",
},
turnDetection: {
type: "server_vad",
threshold: 0.5,
prefixPaddingMs: 300,
silenceDurationMs: 500,
},
inputAudioFormat: "pcm16",
outputAudioFormat: "pcm16",
});
// Subscribe to events
const subscription = session.subscribe({
onResponseAudioDelta: async (event, context) => {
// Handle streaming audio output
const audioData = event.delta;
playAudioChunk(audioData);
},
onResponseTextDelta: async (event, context) => {
// Handle streaming text
process.stdout.write(event.delta);
},
onInputAudioTranscriptionCompleted: async (event, context) => {
console.log("User said:", event.transcript);
},
});
// Send audio from microphone
function sendAudioChunk(audioBuffer: ArrayBuffer) {
session.sendAudio(audioBuffer);
}Session Configuration
await session.updateSession({
// Modalities
modalities: ["audio", "text"],
// System instructions
instructions: "You are a customer service representative.",
// Voice selection
voice: {
type: "azure-standard", // or "azure-custom", "openai"
name: "en-US-AvaNeural",
},
// Turn detection (VAD)
turnDetection: {
type: "server_vad", // or "azure_semantic_vad"
threshold: 0.5,
prefixPaddingMs: 300,
silenceDurationMs: 500,
},
// Audio formats
inputAudioFormat: "pcm16",
outputAudioFormat: "pcm16",
// Tools (function calling)
tools: [
{
type: "function",
name: "get_weather",
description: "Get current weather",
parameters: {
type: "object",
properties: {
location: { type: "string" }
},
required: ["location"]
}
}
],
toolChoice: "auto",
});Event Handling (Azure SDK Pattern)
The SDK uses a subscription-based event handling pattern:
const subscription = session.subscribe({
// Connection lifecycle
onConnected: async (args, context) => {
console.log("Connected:", args.connectionId);
},
onDisconnected: async (args, context) => {
console.log("Disconnected:", args.code, args.reason);
},
onError: async (args, context) => {
console.error("Error:", args.error.message);
},
// Session events
onSessionCreated: async (event, context) => {
console.log("Session created:", context.sessionId);
},
onSessionUpdated: async (event, context) => {
console.log("Session updated");
},
// Audio input events (VAD)
onInputAudioBufferSpeechStarted: async (event, context) => {
console.log("Speech started at:", event.audioStartMs);
},
onInputAudioBufferSpeechStopped: async (event, context) => {
console.log("Speech stopped at:", event.audioEndMs);
},
// Transcription events
onConversationItemInputAudioTranscriptionCompleted: async (event, context) => {
console.log("User said:", event.transcript);
},
onConversationItemInputAudioTranscriptionDelta: async (event, context) => {
process.stdout.write(event.delta);
},
// Response events
onResponseCreated: async (event, context) => {
console.log("Response started");
},
onResponseDone: async (event, context) => {
console.log("Response complete");
},
// Streaming text
onResponseTextDelta: async (event, context) => {
process.stdout.write(event.delta);
},
onResponseTextDone: async (event, context) => {
console.log("\n--- Text complete ---");
},
// Streaming audio
onResponseAudioDelta: async (event, context) => {
const audioData = event.delta;
playAudioChunk(audioData);
},
onResponseAudioDone: async (event, context) => {
console.log("Audio complete");
},
// Audio transcript (what assistant said)
onResponseAudioTranscriptDelta: async (event, context) => {
process.stdout.write(event.delta);
},
// Function calling
onResponseFunctionCallArgumentsDone: async (event, context) => {
if (event.name === "get_weather") {
const args = JSON.parse(event.arguments);
const result = await getWeather(args.location);
await session.addConversationItem({
type: "function_call_output",
callId: event.callId,
output: JSON.stringify(result),
});
await session.sendEvent({ type: "response.create" });
}
},
// Catch-all for debugging
onServerEvent: async (event, context) => {
console.log("Event:", event.type);
},
});
// Clean up when done
await subscription.close();Function Calling
// Define tools in session config
await session.updateSession({
modalities: ["audio", "text"],
instructions: "Help users with weather information.",
tools: [
{
type: "function",
name: "get_weather",
description: "Get current weather for a location",
parameters: {
type: "object",
properties: {
location: {
type: "string",
description: "City and state or country",
},
},
required: ["location"],
},
},
],
toolChoice: "auto",
});
// Handle function calls
const subscription = session.subscribe({
onResponseFunctionCallArgumentsDone: async (event, context) => {
if (event.name === "get_weather") {
const args = JSON.parse(event.arguments);
const weatherData = await fetchWeather(args.location);
// Send function result
await session.addConversationItem({
type: "function_call_output",
callId: event.callId,
output: JSON.stringify(weatherData),
});
// Trigger response generation
await session.sendEvent({ type: "response.create" });
}
},
});Voice Options
| Voice Type | Config | Example |
|---|---|---|
| Azure Standard | { type: "azure-standard", name: "..." } | "en-US-AvaNeural" |
| Azure Custom | { type: "azure-custom", name: "...", endpointId: "..." } | Custom voice endpoint |
| Azure Personal | { type: "azure-personal", speakerProfileId: "..." } | Personal voice clone |
| OpenAI | { type: "openai", name: "..." } | "alloy", "echo", "shimmer" |
Supported Models
| Model | Description | Use Case |
|---|---|---|
gpt-4o-realtime-preview | GPT-4o with real-time audio | High-quality conversational AI |
gpt-4o-mini-realtime-preview | Lightweight GPT-4o | Fast, efficient interactions |
phi4-mm-realtime | Phi multimodal | Cost-effective applications |
Turn Detection Options
// Server VAD (default)
turnDetection: {
type: "server_vad",
threshold: 0.5,
prefixPaddingMs: 300,
silenceDurationMs: 500,
}
// Azure Semantic VAD (smarter detection)
turnDetection: {
type: "azure_semantic_vad",
}
// Azure Semantic VAD (English optimized)
turnDetection: {
type: "azure_semantic_vad_en",
}
// Azure Semantic VAD (Multilingual)
turnDetection: {
type: "azure_semantic_vad_multilingual",
}Audio Formats
| Format | Sample Rate | Use Case |
|---|---|---|
pcm16 | 24kHz | Default, high quality |
pcm16-8000hz | 8kHz | Telephony |
pcm16-16000hz | 16kHz | Voice assistants |
g711_ulaw | 8kHz | Telephony (US) |
g711_alaw | 8kHz | Telephony (EU) |
Key Types Reference
| Type | Purpose |
|---|---|
VoiceLiveClient | Main client for creating sessions |
VoiceLiveSession | Active WebSocket session |
VoiceLiveSessionHandlers | Event handler interface |
VoiceLiveSubscription | Active event subscription |
ConnectionContext | Context for connection events |
SessionContext | Context for session events |
ServerEventUnion | Union of all server events |
Error Handling
import {
VoiceLiveError,
VoiceLiveConnectionError,
VoiceLiveAuthenticationError,
VoiceLiveProtocolError,
} from "@azure/ai-voicelive";
const subscription = session.subscribe({
onError: async (args, context) => {
const { error } = args;
if (error instanceof VoiceLiveConnectionError) {
console.error("Connection error:", error.message);
} else if (error instanceof VoiceLiveAuthenticationError) {
console.error("Auth error:", error.message);
} else if (error instanceof VoiceLiveProtocolError) {
console.error("Protocol error:", error.message);
}
},
onServerError: async (event, context) => {
console.error("Server error:", event.error?.message);
},
});Logging
import { setLogLevel } from "@azure/logger";
// Enable verbose logging
setLogLevel("info");
// Or via environment variable
// AZURE_LOG_LEVEL=infoBrowser Usage
// Browser requires bundler (Vite, webpack, etc.)
import { VoiceLiveClient } from "@azure/ai-voicelive";
import { InteractiveBrowserCredential } from "@azure/identity";
// Use browser-compatible credential
const credential = new InteractiveBrowserCredential({
clientId: "your-client-id",
tenantId: "your-tenant-id",
});
const client = new VoiceLiveClient(endpoint, credential);
// Request microphone access
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const audioContext = new AudioContext({ sampleRate: 24000 });
// Process audio and send to session
// ... (see samples for full implementation)Best Practices
Use
DefaultAzureCredentialfor local development; useManagedIdentityCredentialorWorkloadIdentityCredentialfor production — Never hardcode API keysSet both modalities — Include
["text", "audio"]for voice assistantsUse Azure Semantic VAD — Better turn detection than basic server VAD
Handle all error types — Connection, auth, and protocol errors
Clean up subscriptions — Call
subscription.close()when doneUse appropriate audio format — PCM16 at 24kHz for best quality
Reference Links
Files
- ATTRIBUTION.mdAdded by AutoGineer982 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md13.5 KiB
- references/audio-streaming.md12.3 KiB
- references/function-calling.md13.5 KiB
references/audio-streaming.md
Audio Streaming Reference
Real-time audio capture and playback patterns for Azure AI Voice Live using the @azure/ai-voicelive TypeScript SDK.
Overview
Voice Live requires bidirectional audio streaming over WebSocket. This reference covers browser microphone capture, PCM format conversion, and audio playback patterns for voice assistants.
Audio Format Requirements
| Property | Default Value | Options |
|---|---|---|
inputAudioFormat | "pcm16" | "pcm16", "g711_alaw", "g711_ulaw" |
outputAudioFormat | "pcm16" | "pcm16" |
| Sample Rate (pcm16) | 24000 Hz | 8000, 16000, 24000 |
| Channels | Mono (1) | - |
Sample Rate Inference
function inferPcmSampleRateFromOutputFormat(outputAudioFormat: string | undefined): number {
if (!outputAudioFormat) return 24000;
const fmt = outputAudioFormat.toLowerCase();
if (fmt === "pcm16") return 24000;
if (fmt === "pcm16-16000hz") return 16000;
if (fmt === "pcm16-8000hz") return 8000;
return 24000;
}Browser Microphone Capture
Pattern A: ScriptProcessorNode (Simple)
Simpler implementation but uses deprecated Web Audio API.
export class SimpleAudioCapture {
private audioContext?: AudioContext;
private mediaStream?: MediaStream;
private scriptProcessor?: ScriptProcessorNode;
private dataCallback: (data: ArrayBuffer) => void;
private readonly targetSampleRate = 24000;
constructor(onData: (data: ArrayBuffer) => void) {
this.dataCallback = onData;
}
async initialize(): Promise<void> {
// Request microphone access
this.mediaStream = await navigator.mediaDevices.getUserMedia({
audio: {
channelCount: 1,
sampleRate: this.targetSampleRate,
echoCancellation: true,
noiseSuppression: true,
},
});
// Create audio context at target sample rate
this.audioContext = new AudioContext({ sampleRate: this.targetSampleRate });
// Create processing chain
const source = this.audioContext.createMediaStreamSource(this.mediaStream);
this.scriptProcessor = this.audioContext.createScriptProcessor(4096, 1, 1);
// Connect nodes
source.connect(this.scriptProcessor);
this.scriptProcessor.connect(this.audioContext.destination);
// Process audio data
this.scriptProcessor.onaudioprocess = (event) => {
const inputData = event.inputBuffer.getChannelData(0);
const pcm16Data = this.convertToPCM16(inputData);
this.dataCallback(pcm16Data.buffer);
};
}
private convertToPCM16(floatData: Float32Array): Int16Array {
const pcm16 = new Int16Array(floatData.length);
for (let i = 0; i < floatData.length; i++) {
const sample = Math.max(-1, Math.min(1, floatData[i]));
pcm16[i] = sample < 0 ? sample * 0x8000 : sample * 0x7fff;
}
return pcm16;
}
stop(): void {
this.scriptProcessor?.disconnect();
this.mediaStream?.getTracks().forEach((track) => track.stop());
this.audioContext?.close();
}
}Pattern B: AudioWorklet (Modern, Recommended)
Uses modern AudioWorklet API with better performance.
// Main thread code
export class AudioWorkletCapture {
private audioContext?: AudioContext;
private mediaStream?: MediaStream;
private workletNode?: AudioWorkletNode;
private onAudioData: (data: Uint8Array) => void;
constructor(onData: (data: Uint8Array) => void) {
this.onAudioData = onData;
}
async start(): Promise<void> {
const ac = new AudioContext();
this.audioContext = ac;
// Load AudioWorklet module
const workletUrl = new URL("worklets/pcm16-downsampler.js", document.baseURI).toString();
await ac.audioWorklet.addModule(workletUrl);
// Get microphone stream
// Disable browser processing - server handles VAD
const stream = await navigator.mediaDevices.getUserMedia({
audio: {
echoCancellation: false,
noiseSuppression: false,
autoGainControl: false,
},
});
this.mediaStream = stream;
// Create processing chain
const source = ac.createMediaStreamSource(stream);
const worklet = new AudioWorkletNode(ac, "pcm16-downsampler");
this.workletNode = worklet;
// Receive processed PCM16 data from worklet
worklet.port.onmessage = (e) => {
const buffer = e.data as ArrayBuffer;
const pcm16Bytes = new Uint8Array(buffer);
this.onAudioData(pcm16Bytes);
};
// Connect with muted output to prevent feedback
const gain = ac.createGain();
gain.gain.value = 0;
source.connect(worklet);
worklet.connect(gain);
gain.connect(ac.destination);
}
stop(): void {
this.workletNode?.disconnect();
this.mediaStream?.getTracks().forEach((track) => track.stop());
this.audioContext?.close();
}
}AudioWorklet Processor (pcm16-downsampler.js)
Save this file in /public/worklets/pcm16-downsampler.js:
class Pcm16DownsamplerProcessor extends AudioWorkletProcessor {
constructor() {
super();
this._targetSampleRate = 24000;
this._inputSampleRate = sampleRate; // Browser's native rate (e.g., 48000)
this._ratio = this._inputSampleRate / this._targetSampleRate;
this._carry = 0;
}
process(inputs) {
const input = inputs[0];
if (!input || input.length === 0) return true;
const channel0 = input[0];
if (!channel0 || channel0.length === 0) return true;
// Downsample by averaging
const outLength = Math.max(0, Math.floor((channel0.length - this._carry) / this._ratio));
if (outLength === 0) return true;
const pcm16 = new Int16Array(outLength);
let outIndex = 0;
let i = this._carry;
while (outIndex < outLength) {
const start = Math.floor(i);
const end = Math.floor(i + this._ratio);
let sum = 0, count = 0;
for (let j = start; j < end && j < channel0.length; j++) {
sum += channel0[j];
count++;
}
const sample = count > 0 ? sum / count : 0;
const clamped = Math.max(-1, Math.min(1, sample));
pcm16[outIndex] = clamped < 0 ? clamped * 0x8000 : clamped * 0x7fff;
outIndex++;
i += this._ratio;
}
this._carry = i - channel0.length;
if (this._carry < 0) this._carry = 0;
// Transfer buffer to main thread
this.port.postMessage(pcm16.buffer, [pcm16.buffer]);
return true;
}
}
registerProcessor("pcm16-downsampler", Pcm16DownsamplerProcessor);Audio Playback
Pattern A: AudioBufferSourceNode Queue
Simple queue-based playback using AudioBufferSourceNode.
export class Pcm16Player {
private readonly audioContext: AudioContext;
private nextStartTime = 0;
private sources: AudioBufferSourceNode[] = [];
private sampleRate: number;
constructor(sampleRate = 24000) {
this.audioContext = new AudioContext();
this.sampleRate = sampleRate;
}
async resume(): Promise<void> {
if (this.audioContext.state !== "running") {
await this.audioContext.resume();
}
}
enqueuePcm16(bytes: Uint8Array): void {
// Convert PCM16 bytes to Float32 for Web Audio API
const floatData = this.pcm16BytesToFloat32(bytes);
// Create audio buffer
const buffer = this.audioContext.createBuffer(1, floatData.length, this.sampleRate);
buffer.getChannelData(0).set(floatData);
// Create and schedule source
const src = this.audioContext.createBufferSource();
src.buffer = buffer;
src.connect(this.audioContext.destination);
// Schedule seamless playback
const now = this.audioContext.currentTime;
if (this.nextStartTime < now) {
this.nextStartTime = now;
}
const startAt = this.nextStartTime;
this.nextStartTime += buffer.duration;
// Track for cleanup
src.onended = () => {
this.sources = this.sources.filter((s) => s !== src);
};
this.sources.push(src);
src.start(startAt);
}
private pcm16BytesToFloat32(bytes: Uint8Array): Float32Array {
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
const sampleCount = Math.floor(bytes.byteLength / 2);
const out = new Float32Array(sampleCount);
for (let i = 0; i < sampleCount; i++) {
const s = view.getInt16(i * 2, true); // Little-endian
out[i] = s / 0x8000;
}
return out;
}
stop(): void {
for (const s of this.sources) {
try {
s.stop();
} catch {
/* ignore */
}
}
this.sources = [];
this.nextStartTime = 0;
}
}Pattern B: AudioWorklet Playback
Better for handling barge-in (user interrupts assistant).
// audio-playback-worklet.js
class AudioPlaybackWorklet extends AudioWorkletProcessor {
constructor() {
super();
this.port.onmessage = this.handleMessage.bind(this);
this.buffer = [];
}
handleMessage(event) {
if (event.data === null) {
// Clear buffer on barge-in
this.buffer = [];
return;
}
// Append Int16 samples
this.buffer.push(...event.data);
}
process(inputs, outputs) {
const output = outputs[0];
const channel = output[0];
if (this.buffer.length > channel.length) {
const toProcess = this.buffer.slice(0, channel.length);
this.buffer = this.buffer.slice(channel.length);
channel.set(toProcess.map((v) => v / 32768)); // Int16 to Float32
} else {
channel.set(this.buffer.map((v) => v / 32768));
this.buffer = [];
}
return true;
}
}
registerProcessor("audio-playback-worklet", AudioPlaybackWorklet);PCM16 Conversion Utilities
// Float32 to PCM16 (for sending to server)
export function floatTo16BitPCM(input: Float32Array): Int16Array {
const output = new Int16Array(input.length);
for (let i = 0; i < input.length; i++) {
const s = Math.max(-1, Math.min(1, input[i] ?? 0));
output[i] = s < 0 ? s * 0x8000 : s * 0x7fff;
}
return output;
}
// PCM16 bytes to Float32 (for playback)
export function pcm16BytesToFloat32LE(bytes: Uint8Array): Float32Array {
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
const sampleCount = Math.floor(bytes.byteLength / 2);
const out = new Float32Array(sampleCount);
for (let i = 0; i < sampleCount; i++) {
const s = view.getInt16(i * 2, true); // Little-endian
out[i] = s / 0x8000;
}
return out;
}
// Int16Array to Uint8Array (for sendAudio)
export function int16ToUint8(int16Array: Int16Array): Uint8Array {
return new Uint8Array(int16Array.buffer);
}Integration with VoiceLiveSession
import { VoiceLiveClient } from "@azure/ai-voicelive";
import { DefaultAzureCredential } from "@azure/identity";
const client = new VoiceLiveClient(endpoint, new DefaultAzureCredential());
const session = await client.startSession("gpt-4o-mini-realtime-preview");
// Configure audio formats
await session.updateSession({
modalities: ["audio", "text"],
inputAudioFormat: "pcm16",
outputAudioFormat: "pcm16",
turnDetection: {
type: "server_vad",
threshold: 0.5,
silenceDurationMs: 500,
},
});
// Initialize audio capture and playback
const player = new Pcm16Player(24000);
const capture = new AudioWorkletCapture((data) => {
session.sendAudio(data);
});
// Handle audio output from assistant
const subscription = session.subscribe({
onResponseAudioDelta: async (event) => {
player.enqueuePcm16(event.delta);
},
onInputAudioBufferSpeechStarted: async () => {
// User started speaking - stop playback (barge-in)
player.stop();
},
});
// Start capture
await capture.start();
await player.resume();
// Cleanup
async function cleanup() {
capture.stop();
player.stop();
await subscription.close();
await session.close();
}Best Practices
Use AudioWorklet over ScriptProcessorNode - Better performance and officially supported
Disable browser audio processing - Set
echoCancellation: falsewhen server handles VADHandle barge-in - Clear playback buffer when user starts speaking
Match sample rates - Ensure capture matches server expectation (usually 24kHz)
Use transferable objects - Pass
ArrayBufferwith transfer list for efficiencyResume AudioContext on user gesture - Browser policy requires user interaction
See Also
SKILL.md - Main skill documentation
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an API key, Needs Node.js
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/skills · .github/plugins/azure-sdk-typescript/skills/azure-ai-voicelive-ts · commit 0696600
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download azure-ai-voicelive-ts.zip