base_audio_filter

Base audio filter interface for input transport audio processing.

This module provides the abstract base class for implementing audio filters that process audio data before VAD and downstream processing in input transports.

class pipecat.audio.filters.base_audio_filter.BaseAudioFilter[source]

Bases: ABC

Base class for input transport audio filters.

This is a base class for input transport audio filters. If an audio filter is provided to the input transport it will be used to process audio before VAD and before pushing it downstream. There are control frames to update filter settings or to enable or disable the filter at runtime.

abstractmethod async start(sample_rate: int)[source]

Initialize the filter when the input transport starts.

This will be called from the input transport when the transport is started. It can be used to initialize the filter. The input transport sample rate is provided so the filter can adjust to that sample rate.

Parameters:

sample_rate – The sample rate of the input transport in Hz.

abstractmethod async stop()[source]

Clean up the filter when the input transport stops.

This will be called from the input transport when the transport is stopping.

abstractmethod async process_frame(frame: FilterControlFrame)[source]

Process control frames for runtime filter configuration.

This will be called when the input transport receives a FilterControlFrame.

Parameters:

frame – The control frame containing filter commands or settings.

abstractmethod async filter(audio: bytes) bytes[source]

Apply the audio filter to the provided audio data.

Parameters:

audio – Raw audio data as bytes to be filtered.

Returns:

Filtered audio data as bytes.