Skip to content

AudioInputProvider

Audio input provider interface for the 'input' pipeline role.

Defined in: src/core/types/providers.ts:1246

Audio input provider interface for the 'input' pipeline role.

Remarks

An AudioInputProvider captures audio from a source (e.g. microphone, file buffer, network stream) and delivers it as AudioChunk objects via the onAudio callback. It is the first stage of the 5-role pipeline:

[AudioInputProvider] -> InputQueue -> [STT] -> [LLM] -> [TTS] -> OutputQueue -> [AudioOutputProvider]
 ^^^^^^^^^^^^^^^^^^

Providers implementing this interface must set roles to include 'input'. Multi-role providers (e.g. NativeSTT) may also include 'stt' when the underlying API handles both capture and transcription internally.

Lifecycle: initialize() -> start() -> audio flows via onAudio -> pause() / resume() -> stop() -> dispose()

Example

import type { AudioInputProvider, AudioChunk, AudioMetadata } from 'composite-voice';

class MyMicrophoneInput implements AudioInputProvider {
  readonly type = 'websocket';
  readonly roles = ['input'] as const;
  private callback?: (chunk: AudioChunk) => void;
  private active = false;

  async initialize() { /* request permissions */ }
  async dispose() { /* release resources */ }
  isReady() { return true; }

  start() { this.active = true; /* begin capture */ }
  stop() { this.active = false; /* end capture */ }
  pause() { /* pause capture */ }
  resume() { /* resume capture */ }
  isActive() { return this.active; }

  onAudio(callback: (chunk: AudioChunk) => void) {
    this.callback = callback;
  }

  getMetadata(): AudioMetadata {
    return { sampleRate: 16000, encoding: 'linear16', channels: 1, bitDepth: 16 };
  }
}

See

Extends

Properties

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
rolesreadonlyreadonly ProviderRole[][]Pipeline roles this provider covers. Remarks Each provider declares which stages of the 5-role audio pipeline it can fulfil. Single-role providers list one role (e.g. ['stt']); multi-role providers list every role they handle (e.g. ['input', 'stt'] for NativeSTT, which manages its own microphone access). The provider resolution algorithm reads this property to assign providers to pipeline slots. Base provider classes set sensible defaults: - BaseSTTProvider: ['stt'] - BaseLLMProvider: ['llm'] - BaseTTSProvider: ['tts'] See - ProviderRole for the possible role values - ResolvedPipeline for the resolved pipeline slotsBaseProvider.rolessrc/core/types/providers.ts:166
typereadonlyProviderTypeundefinedThe communication type this provider uses. See ProviderTypeBaseProvider.typesrc/core/types/providers.ts:144

Methods

dispose()

dispose(): Promise<void>;

Defined in: src/core/types/providers.ts:186

Clean up resources and dispose of the provider.

Returns

Promise<void>

Remarks

Called by CompositeVoice during agent shutdown. The provider should close any open connections, clear buffers, and release resources.

Inherited from

BaseProvider.dispose


getMetadata()

getMetadata(): AudioMetadata;

Defined in: src/core/types/providers.ts:1313

Get the audio format metadata for the captured audio.

Returns

AudioMetadata

AudioMetadata describing the audio format

Remarks

Returns metadata describing the format of audio chunks this provider will emit. Used by the pipeline to auto-configure the STT provider’s encoding, sample rate, and channel settings.

See

AudioMetadata for the metadata type


initialize()

initialize(): Promise<void>;

Defined in: src/core/types/providers.ts:177

Initialize the provider and allocate any required resources.

Returns

Promise<void>

Remarks

Called by CompositeVoice during agent startup. The provider should be ready to process requests after this method resolves.

Throws

Error if initialization fails (e.g., invalid API key, network error)

Inherited from

BaseProvider.initialize


isActive()

isActive(): boolean;

Defined in: src/core/types/providers.ts:1288

Check whether the input source is actively capturing audio.

Returns

boolean

true when audio is being captured (between start() and stop(), and not paused)


isReady()

isReady(): boolean;

Defined in: src/core/types/providers.ts:193

Check if the provider is initialized and ready to process requests.

Returns

boolean

true if the provider has been initialized and is operational

Inherited from

BaseProvider.isReady


onAudio()

onAudio(callback): void;

Defined in: src/core/types/providers.ts:1299

Register a callback to receive captured audio chunks.

Parameters

ParameterTypeDescription
callback(chunk) => voidFunction invoked with each AudioChunk

Returns

void

Remarks

The provider calls this callback with each chunk of captured audio. Must be called before start.


pause()

pause(): void;

Defined in: src/core/types/providers.ts:1273

Temporarily pause audio capture without releasing the source.

Returns

void

Remarks

Used by the turn-taking system to mute capture during TTS playback. Resume with resume.


resume()

resume(): void;

Defined in: src/core/types/providers.ts:1280

Resume audio capture after a pause.

Returns

void

See

pause


start()

start(): void;

Defined in: src/core/types/providers.ts:1255

Start capturing audio from the input source.

Returns

void

Remarks

After calling start(), the provider begins delivering audio chunks via the callback registered with onAudio. Must be called after initialize.


stop()

stop(): void;

Defined in: src/core/types/providers.ts:1264

Stop capturing audio and release the input source.

Returns

void

Remarks

Stops audio delivery. The provider can be restarted with start.

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency