Expose Cartesia STT turn detection options - #2156
Closed
rosetta-livekit-bot[bot] wants to merge 1 commit into
Closed
Expose Cartesia STT turn detection options#2156rosetta-livekit-bot[bot] wants to merge 1 commit into
rosetta-livekit-bot[bot] wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: d6718ab The changes in this PR will be included in the next version bump. This PR includes changesets to release 39 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
done in #2173 |
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
ink-2STT turn-detection thresholds andkeytermoptions onSTTOptions./stt/turns/websocketquery parameters, preserving repeatedkeytermvalues.ink-whisperSTT models.Source diff coverage
livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/_recognize_streams/auto_finalize_recognize_stream.pyplugins/cartesia/src/stt.ts. The JS plugin keeps the turn-detecting websocket stream in the main STT file rather than a separate recognize-stream module, so the constructor/storage changes map toSTTOptionsandSpeechStream, and websocket query serialization maps toSpeechStream.#getCartesiaUrl().livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/stt.pyplugins/cartesia/src/stt.ts. Added public STT options, legacy-model validation, option storage/updates, and propagation to the turn-detecting websocket stream.Testing
pnpm test plugins/cartesiapnpm --filter @livekit/agents-plugin-cartesia buildpnpm --filter @livekit/agents-plugin-cartesia lintpnpm --filter @livekit/agents-plugin-cartesia api:checkpnpm buildpnpm lint(completed successfully; existing warnings are emitted in unrelated packages)Ported from livekit/agents#6594
Original PR description
Sibling of #6587 (same pattern for xAI STT): exposes the turn-detection tuning parameters documented for Cartesia's
/stt/turns/websocket(https://docs.cartesia.ai/api-reference/stt/turns/websocket) oncartesia.STT:turn_start_threshold(0.5–0.9, default 0.8) — likelihood above which a turn startsturn_eager_end_threshold(0.3–0.6, default 0.4) — likelihood below whichturn.eager_endfiresturn_end_threshold(0.05–0.5, default 0.2) — likelihood below which the turn endsturn_end_timeout_ms(640–11200, default 5600) — silence backstop for ending a turnkeyterm(list, up to 100 terms / 1200 chars) — recall biasing; sent as repeated query params, so the turns-websocketparamsdict became a list of pairsThese are the primary tuning levers when running ink-2 with
turn_detection="stt"in anAgentSession— today the plugin connects to the turns endpoint with no way to adjust them. All five areNotGivenOrand omitted when unset, so the default connection sends the identical query string as before. Passing any of them with a non-turn-detecting model (ink-whisper → the legacy endpoint) raisesValueError, mirroring the model-gated params in the AssemblyAI plugin.Live-verified against
wss://api.cartesia.ai/stt/turns/websocket(real key, today):turn_start_threshold=0.85, repeatedkeyterm) →{"type":"connected", ...}turn_start_threshold=2.0) → error frame"turn_start_threshold must be between 0.5 and 0.9."+ close — so the server parses and validates exactly these param names (unknown params are silently ignored, which is why the client-sideValueErrorguard is worth having)Verified with
ruff check/ruff format.🤖 Generated with Claude Code