@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
new AudioManager(config): AudioManager;Defined in: lib/vowel/managers/AudioManager.ts:78
Parameters
| Parameter | Type |
|---|---|
config | AudioManagerConfig |
Returns
AudioManager
Methods
initAudio()
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()
setupMicrophone(
provider,
onStatusUpdate?,
deviceId?): Promise<void>;Defined in: lib/vowel/managers/AudioManager.ts:201
Setup microphone and start streaming to session
Parameters
| Parameter | Type | Description |
|---|---|---|
provider | RealtimeProvider | The realtime provider to stream audio to |
onStatusUpdate? | (status) => void | Callback for status updates |
deviceId? | string | Optional 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()
playAudio(audioData): Promise<void>;Defined in: lib/vowel/managers/AudioManager.ts:475
Play audio data (from AI response)
Parameters
| Parameter | Type | Description |
|---|---|---|
audioData | string | ArrayBuffer | Either base64 string or ArrayBuffer |
Returns
Promise<void>
playTypingSound()
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
audioData | Uint8Array | undefined | PCM16 audio data (Uint8Array) |
volume | number | 0.3 | Volume multiplier (0.0 to 1.0) |
Returns
AudioBufferSourceNode | null
AudioBufferSourceNode instance
stopTypingSounds()
stopTypingSounds(): void;Defined in: lib/vowel/managers/AudioManager.ts:599
Stop all typing sounds immediately
Returns
void
stopAllAudio()
stopAllAudio(): void;Defined in: lib/vowel/managers/AudioManager.ts:627
Stop all audio playback (e.g., on interruption)
Returns
void
getAvailableDevices()
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
requirePermission | boolean | false | If true, request getUserMedia first (requires user gesture on iOS) |
Returns
Promise<MediaDeviceInfo[]>
Promise resolving to array of MediaDeviceInfo for audio inputs
hasMicrophonePermission()
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()
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()
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()
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
| Parameter | Type | Description |
|---|---|---|
deviceId | string | The device ID to switch to |
provider? | RealtimeProvider | The realtime provider (required if microphone is already set up) |
onStatusUpdate? | (status) => void | Optional status update callback |
Returns
Promise<void>
cleanup()
cleanup(): void;Defined in: lib/vowel/managers/AudioManager.ts:794
Cleanup all audio resources
Returns
void
getMediaStream()
getMediaStream(): MediaStream | null;Defined in: lib/vowel/managers/AudioManager.ts:838
Get the media stream for VAD integration
Returns
MediaStream | null
isInitialized()
isInitialized(): boolean;Defined in: lib/vowel/managers/AudioManager.ts:845
Check if audio is initialized
Returns
boolean
isStreaming()
isStreaming(): boolean;Defined in: lib/vowel/managers/AudioManager.ts:852
Check if microphone is streaming
Returns
boolean
setMuted()
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
| Parameter | Type |
|---|---|
muted | boolean |
Returns
void
isMutedState()
isMutedState(): boolean;Defined in: lib/vowel/managers/AudioManager.ts:872
Check if audio input is muted
Returns
boolean