Skip to content

Add Krisp API key support and debug logging#3809

Merged
markbackman merged 3 commits intomainfrom
mb/krisp-viva-result
Feb 25, 2026
Merged

Add Krisp API key support and debug logging#3809
markbackman merged 3 commits intomainfrom
mb/krisp-viva-result

Conversation

@markbackman
Copy link
Copy Markdown
Contributor

@markbackman markbackman commented Feb 24, 2026

Context

The motivation for this PR is to provide transparency to the metrics data for KrispVivaTurn. I took the opportunity to also remove dead code fields in the SmartTurnMetricsData and created a generic TurnMetricsData class.

While working on that, I found that the new Krisp SDK requires an API key, so I added support for that too, in 3bb9b07.

Summary

  • Added TurnMetricsData as a generic metrics class for turn detection, replacing the service-specific SmartTurnMetricsData. KrispVivaTurn now emits TurnMetricsData with e2e_processing_time_ms measuring the interval from VAD speech-to-silence transition to model threshold crossing.
  • BaseSmartTurn now emits TurnMetricsData instead of SmartTurnMetricsData. Deprecated SmartTurnMetricsData (still available as a subclass for backwards compatibility).
  • MetricsLogObserver normalizes deprecated SmartTurnMetricsData in include_metrics filters and logs all turn metrics via a unified _log_turn handler.
  • Metrics are consumed in the strategy _handle_input_audio path when append_audio returns COMPLETE, so they are pushed immediately while fresh.
  • Added api_key parameter to KrispVivaSDKManager, KrispVivaTurn, and KrispVivaFilter for Krisp SDK v1.8.0 licensing. Falls back to KRISP_VIVA_API_KEY environment variable.
  • Updated examples (07p, 38b) to use TurnMetricsData and MetricsLogObserver.

Testing

  • Run 07p-interruptible-krisp-viva.py with KRISP_VIVA_API_KEY set and verify turn metrics are logged with e2e processing time
  • Run 38b-smart-turn-local.py and verify TurnMetricsData metrics appear in logs
  • Verify include_metrics={SmartTurnMetricsData} still works (with deprecation warning)

markbackman added a commit that referenced this pull request Feb 24, 2026
@markbackman markbackman force-pushed the mb/krisp-viva-result branch 2 times, most recently from 84e671a to aeca6de Compare February 24, 2026 02:33
…mple

Move speech detection tracking outside the per-frame loop in append_audio
since is_speech applies to the whole buffer. Add debug log in
analyze_end_of_turn to show state and probability at decision time. Update
the Krisp VIVA example to use Cartesia TTS and turn analyzer strategy.
("07n-interruptible-google.py", EVAL_SIMPLE_MATH),
("07n-interruptible-google-http.py", EVAL_SIMPLE_MATH),
("07o-interruptible-assemblyai.py", EVAL_SIMPLE_MATH),
("07p-interruptible-krisp-viva.py", EVAL_SIMPLE_MATH),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aconchillo I can provide the Krisp SDK and model for running release evals.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 32.60870% with 31 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pipecat/audio/turn/krisp_viva_turn.py 0.00% 18 Missing ⚠️
.../pipecat/observers/loggers/metrics_log_observer.py 0.00% 8 Missing ⚠️
src/pipecat/audio/krisp_instance.py 80.00% 2 Missing ⚠️
...user_stop/turn_analyzer_user_turn_stop_strategy.py 0.00% 2 Missing ⚠️
...c/pipecat/audio/turn/smart_turn/base_smart_turn.py 50.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/pipecat/audio/filters/krisp_viva_filter.py 91.83% <100.00%> (+0.08%) ⬆️
src/pipecat/metrics/metrics.py 100.00% <100.00%> (ø)
...c/pipecat/audio/turn/smart_turn/base_smart_turn.py 46.36% <50.00%> (+2.01%) ⬆️
src/pipecat/audio/krisp_instance.py 76.19% <80.00%> (-0.13%) ⬇️
...user_stop/turn_analyzer_user_turn_stop_strategy.py 79.62% <0.00%> (-1.51%) ⬇️
.../pipecat/observers/loggers/metrics_log_observer.py 0.00% <0.00%> (ø)
src/pipecat/audio/turn/krisp_viva_turn.py 0.00% <0.00%> (ø)

... and 45 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@markbackman markbackman changed the title Add debug logging to KrispVivaTurn analyze_end_of_turn Add Krisp API key support and debug logging Feb 24, 2026
@markbackman markbackman requested review from aconchillo and filipi87 and removed request for aconchillo and filipi87 February 24, 2026 20:05

# Extract metrics from the nested structure
metrics = result.get("metrics", {})
inference_time = metrics.get("inference_time", 0)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields weren't populated, so removing them along with SmartTurnMetricsData.

@markbackman markbackman force-pushed the mb/krisp-viva-result branch 2 times, most recently from a0804c2 to 10ce2d8 Compare February 24, 2026 22:53
Comment on lines +55 to +56
api_key: Krisp SDK API key. If empty, falls back to
the KRISP_API_KEY environment variable.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markbackman, is this something new? As far as I remember, we never needed an API key for Krisp before. Is it required now?

If it is required, we should probably update our docs as well:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Docs PR: pipecat-ai/docs#548

key = api_key or os.environ.get("KRISP_API_KEY", "")
try:
# New SDK signature (requires license key)
krisp_audio.globalInit(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even in Krisp’s own documentation, I don’t see an API key being required:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, this isn't well documented, but it is required. You can find it in the SDK ref docs when you download the SDK. The Krisp team confirmed version 1.6.1 and newer require it.

Comment thread env.example Outdated
KRISP_MODEL_PATH=...

# Krisp Viva
KRISP_API_KEY=...
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call it KRISP_VIVA_API_KEY to match the other environment variables?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Yes. I'll do that now.

Copy link
Copy Markdown
Contributor

@filipi87 filipi87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming with Krisp. LGTM!

The Krisp VIVA SDK v1.8.0 requires a license key in globalInit(). Add
api_key parameter to KrispVivaSDKManager, KrispVivaTurn, and
KrispVivaFilter with fallback to KRISP_API_KEY env var. Maintain
backwards compatibility with older SDK versions by catching TypeError
and falling back to the old 3-arg signature.
Introduce a generic TurnMetricsData class for turn detection metrics,
replacing the service-specific SmartTurnMetricsData (now deprecated).
Add end-to-end processing time measurement to KrispVivaTurn, tracking
the interval from VAD speech-to-silence transition to model threshold
crossing. Consume metrics in the strategy _handle_input_audio path
so they are pushed immediately when fresh.
@markbackman markbackman merged commit 3e6c59c into main Feb 25, 2026
5 checks passed
@markbackman markbackman deleted the mb/krisp-viva-result branch February 25, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants