krisp_viva_filter

Krisp noise reduction audio filter for Pipecat.

This module provides an audio filter implementation using Krisp VIVA SDK.

class pipecat.audio.filters.krisp_viva_filter.KrispVivaFilter(model_path: str = None, frame_duration: int = 10, noise_suppression_level: int = 100, api_key: str = '')[source]

Bases: BaseAudioFilter

Audio filter using the Krisp VIVA SDK.

Provides real-time noise reduction for audio streams using Krisp’s proprietary noise suppression algorithms. This filter requires a valid Krisp model file to operate.

__init__(model_path: str = None, frame_duration: int = 10, noise_suppression_level: int = 100, api_key: str = '') None[source]

Initialize the Krisp noise reduction filter.

Parameters:
  • model_path – Path to the Krisp model file (.kef extension). If None, uses KRISP_VIVA_FILTER_MODEL_PATH environment variable.

  • frame_duration – Frame duration in milliseconds.

  • noise_suppression_level – Noise suppression level.

  • api_key – Krisp SDK API key. If empty, falls back to the KRISP_VIVA_API_KEY environment variable.

Raises:
  • ValueError – If model_path is not provided and KRISP_VIVA_FILTER_MODEL_PATH is not set.

  • Exception – If model file doesn’t have .kef extension.

  • FileNotFoundError – If model file doesn’t exist.

  • RuntimeError – If Krisp SDK initialization fails.

async start(sample_rate: int)[source]

Initialize the Krisp processor with the transport’s sample rate.

Parameters:

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

async stop()[source]

Clean up the Krisp processor when stopping.

async process_frame(frame: FilterControlFrame)[source]

Process control frames to enable/disable filtering.

Parameters:

frame – The control frame containing filter commands.

async filter(audio: bytes) bytes[source]

Apply Krisp noise reduction to audio data.

Parameters:

audio – Raw audio data as bytes to be filtered.

Returns:

Noise-reduced audio data as bytes.