Skip to content

fix(elevenlabs): populate SpeechData.confidence from Scribe logprobs#6461

Open
captainbanan wants to merge 1 commit into
livekit:mainfrom
captainbanan:fix/elevenlabs-stt-confidence
Open

fix(elevenlabs): populate SpeechData.confidence from Scribe logprobs#6461
captainbanan wants to merge 1 commit into
livekit:mainfrom
captainbanan:fix/elevenlabs-stt-confidence

Conversation

@captainbanan

@captainbanan captainbanan commented Jul 17, 2026

Copy link
Copy Markdown

What / Why

The ElevenLabs STT plugin never populates SpeechData.confidence, so it always stays at its 0.0 default — even though Scribe returns a per-word logprob in every response. Consumers that use confidence (e.g. to tell a clean transcript from a low-confidence / garbled one) get no signal from ElevenLabs.

Verified live: both scribe_v1/scribe_v2 (REST) and scribe_v2_realtime return a natural-log logprob per words[] token, but _process_stream_event / _transcription_to_speech_event read only text + word start/end, so it is discarded and confidence stays 0.0.

Change

Add _speech_confidence(words): average the spoken-word (type == "word") logprobs and exponentiate → a [0, 1] confidence (geometric mean of the token probabilities). Returns 0.0 when per-word logprobs aren't available (e.g. a non-timestamped commit), so behaviour is unchanged there.

Wired into both the REST and WebSocket SpeechData construction.

Note: this deliberately does not use Scribe's language_probability — that is language-identification confidence, a different quantity from transcription confidence, so folding it into SpeechData.confidence would be misleading.

Same class of fix as #5829 / #5830 (a sibling STT plugin not threading its confidence into SpeechData).

Tests

Unit tests for the helper (confident vs low-confidence logprobs, no-logprob → 0.0) and an end-to-end check that a committed transcript sets confidence. ruff check / ruff format clean.

🤖 Generated with Claude Code

@CLAassistant

CLAassistant commented Jul 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

…robs

The ElevenLabs STT plugin never set SpeechData.confidence, so it always
defaulted to 0.0 even though Scribe returns a per-word `logprob` in its
response (REST and realtime). Consumers that rely on transcription
confidence get no signal.

Average the spoken-word logprobs and exponentiate to a [0, 1] probability
(geometric mean of the token probabilities), applied on both the REST and
WebSocket paths. Returns 0.0 when per-word logprobs are unavailable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@captainbanan
captainbanan force-pushed the fix/elevenlabs-stt-confidence branch from 8ba5965 to 37d4128 Compare July 17, 2026 08:39
@captainbanan
captainbanan marked this pull request as ready for review July 17, 2026 08:54
@captainbanan
captainbanan requested a review from a team as a code owner July 17, 2026 08:54

@devin-ai-integration devin-ai-integration Bot left a comment

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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

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