krisp_instance

Krisp Instance manager for pipecat audio.

pipecat.audio.krisp_instance.int_to_krisp_sample_rate(sample_rate: int)[source]

Convert integer sample rate to Krisp SDK enum value.

Parameters:

sample_rate – Sample rate in Hz (e.g., 16000, 24000, 48000).

Returns:

Corresponding Krisp SDK SampleRate enum value.

Raises:

ValueError – If the sample rate is not supported by Krisp SDK.

pipecat.audio.krisp_instance.int_to_krisp_frame_duration(frame_duration_ms: int)[source]

Convert integer frame duration to Krisp SDK enum value.

Parameters:

frame_duration_ms – Frame duration in milliseconds (e.g., 10, 20, 30).

Returns:

Corresponding Krisp SDK FrameDuration enum value.

Raises:

ValueError – If the frame duration is not supported by Krisp SDK.

pipecat.audio.krisp_instance.krisp_sdk_uses_nanobind_bindings() → bool[source]

Whether the installed krisp_audio build uses nanobind bindings (>= 1.11.0).

class pipecat.audio.krisp_instance.KrispVivaSDKManager[source]

Bases: object

Singleton manager for Krisp VIVA SDK with reference counting.

The SDK’s global state is shared by every Krisp session in the process, so it is initialized once, on first use, and left up for the life of the process: destroying it while any session is still alive leaves that session reading freed memory, and there is no point in the process where every session is known to be gone. The reference count tracks how many components hold the SDK; it does not decide when to tear it down.

classmethod acquire(api_key: str = '')[source]

Acquire a reference to the SDK (initializes if needed).

Call this before creating Krisp sessions.

Parameters:

api_key – Krisp SDK API key. If empty, falls back to the KRISP_VIVA_API_KEY environment variable. Only the key of the caller that initializes the SDK is used.

Raises:

Exception – If SDK initialization fails (propagated from krisp_audio)

classmethod release()[source]

Release a reference to the SDK.

Call this once the caller’s Krisp sessions are gone. Releasing the last reference does not tear the SDK down; see the class docstring.

classmethod get_reference_count() → int[source]

Get the current reference count.

Returns:

Current number of active references to the SDK.

classmethod is_initialized() → bool[source]

Check if the SDK is currently initialized.

Returns:

True if SDK is initialized, False otherwise.