feat(sarvam): expose max_session_duration as TTS constructor parameter#5430
Open
KeWang0622 wants to merge 1 commit intolivekit:mainfrom
Open
feat(sarvam): expose max_session_duration as TTS constructor parameter#5430KeWang0622 wants to merge 1 commit intolivekit:mainfrom
KeWang0622 wants to merge 1 commit intolivekit:mainfrom
Conversation
The WebSocket connection pool's max_session_duration was hardcoded to 3600 seconds, forcing connection reuse across all TTS requests. Users who need a fresh connection per request (e.g. to avoid audio quality degradation from stale server-side session state) had to reach into private attributes. Add max_session_duration as a public constructor parameter on sarvam.TTS, with the same default (3600s). Setting it to 0 gives a fresh WebSocket per request. Closes livekit#5268
|
|
Author
|
CLA signed via https://cla-assistant.io/livekit/agents?pullRequest=5430 |
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
Closes #5268
The Sarvam TTS plugin's WebSocket connection pool hardcodes
max_session_durationto 3600 seconds, making it impossible to control connection reuse without reaching into private attributes (tts._pool._max_session_duration = 0).This PR exposes
max_session_durationas a public constructor parameter onsarvam.TTS:Changes:
max_session_durationfield toSarvamTTSOptionsdataclass (default:3600)max_session_durationparameter toTTS.__init__()with validation (>= 0)utils.ConnectionPoolinstead of the hardcoded3600Behavior:
max_session_duration=3600(default) — existing behavior, connections reused for up to 1 hourmax_session_duration=0— fresh WebSocket per request, no reuse (may improve audio quality as noted in the issue)max_session_duration=N— custom reuse window in secondsNo breaking changes — the default matches the previous hardcoded value.
Test plan
sarvam.TTS(target_language_code="hi-IN", max_session_duration=0)creates a fresh connection per requestmax_session_durationarg) is unchangedmax_session_duration=-1raisesValueErrorruff checkandruff formatpass