Skip to content

@vowel.to/client v0.1.2-393


@vowel.to/client / index / AudioManager

Class: AudioManager

Defined in: lib/vowel/managers/AudioManager.ts:57

Audio Manager class Handles microphone setup, audio streaming, and playback

Constructors

Constructor

ts
new AudioManager(config): AudioManager;

Defined in: lib/vowel/managers/AudioManager.ts:78

Parameters

ParameterType
configAudioManagerConfig

Returns

AudioManager

Methods

initAudio()

ts
initAudio(): Promise<void>;

Defined in: lib/vowel/managers/AudioManager.ts:91

Initialize audio contexts for input and output Also loads the AudioWorklet processor module

CRITICAL for iOS: This must be called synchronously within a user gesture handler. iOS Safari requires AudioContext creation and resume() to happen within the same user gesture event handler. Any async operations between gesture and resume() will cause the AudioContext to remain suspended.

Returns

Promise<void>


setupMicrophone()

ts
setupMicrophone(
   provider, 
   onStatusUpdate?, 
deviceId?): Promise<void>;

Defined in: lib/vowel/managers/AudioManager.ts:201

Setup microphone and start streaming to session

Parameters

ParameterTypeDescription
providerRealtimeProviderThe realtime provider to stream audio to
onStatusUpdate?(status) => voidCallback for status updates
deviceId?stringOptional device ID to use (if not provided, uses default or previously selected device) CRITICAL for iOS: This must be called within a user gesture handler chain. getUserMedia() requires user gesture on iOS Safari.

Returns

Promise<void>


playAudio()

ts
playAudio(audioData): Promise<void>;

Defined in: lib/vowel/managers/AudioManager.ts:475

Play audio data (from AI response)

Parameters

ParameterTypeDescription
audioDatastring | ArrayBufferEither base64 string or ArrayBuffer

Returns

Promise<void>


playTypingSound()

ts
playTypingSound(audioData, volume): AudioBufferSourceNode | null;

Defined in: lib/vowel/managers/AudioManager.ts:543

Play typing sound segment Uses separate audio source queue to allow immediate stopping

Parameters

ParameterTypeDefault valueDescription
audioDataUint8ArrayundefinedPCM16 audio data (Uint8Array)
volumenumber0.3Volume multiplier (0.0 to 1.0)

Returns

AudioBufferSourceNode | null

AudioBufferSourceNode instance


stopTypingSounds()

ts
stopTypingSounds(): void;

Defined in: lib/vowel/managers/AudioManager.ts:599

Stop all typing sounds immediately

Returns

void


stopAllAudio()

ts
stopAllAudio(): void;

Defined in: lib/vowel/managers/AudioManager.ts:627

Stop all audio playback (e.g., on interruption)

Returns

void


getAvailableDevices()

ts
getAvailableDevices(requirePermission): Promise<MediaDeviceInfo[]>;

Defined in: lib/vowel/managers/AudioManager.ts:677

Get available audio input devices

Note: On iOS Safari, getUserMedia must be called from a user gesture context to get device labels. If permission hasn't been granted, this will return devices with empty labels.

Parameters

ParameterTypeDefault valueDescription
requirePermissionbooleanfalseIf true, request getUserMedia first (requires user gesture on iOS)

Returns

Promise<MediaDeviceInfo[]>

Promise resolving to array of MediaDeviceInfo for audio inputs


hasMicrophonePermission()

ts
hasMicrophonePermission(): Promise<boolean>;

Defined in: lib/vowel/managers/AudioManager.ts:705

Check if microphone permission has been granted

Returns

Promise<boolean>

Promise resolving to true if permission granted, false otherwise


requestMicrophonePermission()

ts
requestMicrophonePermission(): Promise<boolean>;

Defined in: lib/vowel/managers/AudioManager.ts:728

Request microphone permission MUST be called from a user gesture handler on iOS Safari

Returns

Promise<boolean>

Promise resolving to true if permission granted, false otherwise


getCurrentDevice()

ts
getCurrentDevice(): MediaDeviceInfo | null;

Defined in: lib/vowel/managers/AudioManager.ts:743

Get the currently active microphone device

Returns

MediaDeviceInfo | null

MediaDeviceInfo for current device, or null if not available


switchDevice()

ts
switchDevice(
   deviceId, 
   provider?, 
onStatusUpdate?): Promise<void>;

Defined in: lib/vowel/managers/AudioManager.ts:754

Switch to a different microphone device This will reinitialize the microphone stream with the new device

Parameters

ParameterTypeDescription
deviceIdstringThe device ID to switch to
provider?RealtimeProviderThe realtime provider (required if microphone is already set up)
onStatusUpdate?(status) => voidOptional status update callback

Returns

Promise<void>


cleanup()

ts
cleanup(): void;

Defined in: lib/vowel/managers/AudioManager.ts:794

Cleanup all audio resources

Returns

void


getMediaStream()

ts
getMediaStream(): MediaStream | null;

Defined in: lib/vowel/managers/AudioManager.ts:838

Get the media stream for VAD integration

Returns

MediaStream | null


isInitialized()

ts
isInitialized(): boolean;

Defined in: lib/vowel/managers/AudioManager.ts:845

Check if audio is initialized

Returns

boolean


isStreaming()

ts
isStreaming(): boolean;

Defined in: lib/vowel/managers/AudioManager.ts:852

Check if microphone is streaming

Returns

boolean


setMuted()

ts
setMuted(muted): void;

Defined in: lib/vowel/managers/AudioManager.ts:860

Mute audio input (stop sending audio to server) WebSocket stays connected, but no audio data is transmitted

Parameters

ParameterType
mutedboolean

Returns

void


isMutedState()

ts
isMutedState(): boolean;

Defined in: lib/vowel/managers/AudioManager.ts:872

Check if audio input is muted

Returns

boolean