Add Krisp VIVA Turn as a user turn-stop strategy#178
Open
weiz9 wants to merge 2 commits into
Open
Conversation
Wire pipecat's KrispVivaTurn (VIVA SDK turn detection v3) into the cascade pipeline as a selectable turn_stop_strategy alongside the existing LocalSmartTurnAnalyzerV3. The analyzer is imported lazily because it depends on the proprietary krisp_audio SDK plus a .kef model and license key, so environments without the SDK are unaffected until the strategy is selected. - turn_config: add 'krisp_viva_turn' branch forwarding threshold/ frame_duration_ms to KrispTurnParams and model_path/api_key/sample_rate to the KrispVivaTurn constructor (both fall back to env vars) - config + .env.example: document the strategy and required env vars (KRISP_VIVA_TURN_MODEL_PATH, KRISP_VIVA_API_KEY) - tests: cover the new branch via an injected fake krisp module - bump simulation_version 2.0.1 -> 2.0.2
weiz9
marked this pull request as ready for review
July 23, 2026 17:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Krisp VIVA Turn (pipecat's
KrispVivaTurn, VIVA SDK turn detection v3 / Tt API) as a selectableturn_stop_strategyin the cascade pipeline, alongside the existingLocalSmartTurnAnalyzerV3. Unlike Smart Turn (which analyzes audio in batches when VAD detects a pause), KrispVivaTurn processes audio frame-by-frame in real time, using the VAD's speech flag as an external signal.Changes
turn_config.py— newkrisp_viva_turnbranch increate_turn_stop_strategy(). Forwardsthreshold/frame_duration_mstoKrispTurnParamsandmodel_path/api_key/sample_rateto theKrispVivaTurnconstructor (all fall back to env vars). The pipecat module is imported lazily because it hard-requires the proprietarykrisp_audioSDK — environments without it are unaffected until the strategy is selected.config.py+.env.example— document the new strategy and required env vars (KRISP_VIVA_TURN_MODEL_PATH,KRISP_VIVA_API_KEY).test_turn_config.py— 4 new tests covering the branch (happy path, case-insensitivity, tuning-param routing, constructor-param routing) via an injected fake krisp module.simulation_version2.0.1 → 2.0.2 (affects benchmark outputs).Enabling it
Krisp is a licensed SDK, not a PyPI package, so it is intentionally not in
pyproject.toml. To run this strategy you provision it at runtime:developers.krisp.ai): the VIVA UAR Python SDK zip and the Turn-Taking models zip. Unzip both.dist/folder — e.g. macOS x86_64 / Py3.11:arm64vsx86_64to matchpython -c "import platform; print(platform.machine())".)Optional tuning via
EVA_MODEL__TURN_STOP_STRATEGY_PARAMS—threshold(default 0.5) andframe_duration_ms(default 20; one of 10/15/20/30/32).Deployment (toolkit / Docker)
The runtime image is
linux/amd64, so it needs the Linux wheel from the same SDK download —krisp_audio-<ver>-cp311-cp311-linux_x86_64.whl(ships alongside the macOS wheels). The wheel +.kefmodel should be baked into the image from an internal artifact store (not committed to git), withKRISP_VIVA_API_KEYinjected as a runtime secret and egress to the two Krisp hosts allowlisted. Tracked as follow-up.Testing
test_turn_config.pyunit tests pass; ruff + version-bump checks pass; no new mypy errors.turn_stop_strategy=krisp_viva_turn; the SDK initialized, loaded the model, and produced 90 real end-of-turn predictions (model probabilities 51–99%, end-of-turn latencies ~0.1 ms–1.5 s, mostly ~100–300 ms). Turn-taking was driven entirely by Krisp.krisp_audiois absent, selecting the strategy fails with a clean, actionable error and no other strategy is affected.