Repository navigation
fix(gradium): stop voice_id default from overriding an explicit voice (1/2) #7813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
longcw
merged 1 commit into
livekit:main
from
hhugo-gradium:fix/gradium-tts-voice-selection
Oct 20, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| """Gradium TTS voice selection: `voice` and `voice_id` are alternatives, never both.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| pytestmark = pytest.mark.unit | ||
|
|
||
|
|
||
| def test_default_voice_id_when_neither_is_given(): | ||
| from livekit.plugins.gradium import TTS | ||
| from livekit.plugins.gradium.tts import DEFAULT_VOICE_ID | ||
|
|
||
| tts = TTS(api_key="test-key") | ||
| assert tts._opts.voice_id == DEFAULT_VOICE_ID | ||
| assert tts._opts.voice is None | ||
|
|
||
|
|
||
| def test_voice_name_is_not_overridden_by_a_default_voice_id(): | ||
| from livekit.plugins.gradium import TTS | ||
|
|
||
| tts = TTS(api_key="test-key", voice="narrator") | ||
| assert tts._opts.voice == "narrator" | ||
| assert tts._opts.voice_id is None | ||
|
|
||
|
|
||
| def test_voice_id_alone_is_kept(): | ||
| from livekit.plugins.gradium import TTS | ||
|
|
||
| tts = TTS(api_key="test-key", voice_id="abc") | ||
| assert tts._opts.voice_id == "abc" | ||
| assert tts._opts.voice is None | ||
|
|
||
|
|
||
| def test_voice_and_voice_id_are_exclusive(): | ||
| from livekit.plugins.gradium import TTS | ||
|
|
||
| with pytest.raises(ValueError, match="mutually exclusive"): | ||
| TTS(api_key="test-key", voice="narrator", voice_id="abc") | ||
|
|
||
|
|
||
| def test_update_options_voice_clears_voice_id(): | ||
| from livekit.plugins.gradium import TTS | ||
|
|
||
| tts = TTS(api_key="test-key") | ||
| tts.update_options(voice="narrator") | ||
| assert tts._opts.voice == "narrator" | ||
| assert tts._opts.voice_id is None | ||
|
|
||
|
|
||
| def test_update_options_voice_id_clears_voice(): | ||
| from livekit.plugins.gradium import TTS | ||
|
|
||
| tts = TTS(api_key="test-key", voice="narrator") | ||
| tts.update_options(voice_id="abc") | ||
| assert tts._opts.voice_id == "abc" | ||
| assert tts._opts.voice is None | ||
|
|
||
|
|
||
| def test_update_options_rejects_both(): | ||
| from livekit.plugins.gradium import TTS | ||
|
|
||
| tts = TTS(api_key="test-key") | ||
| with pytest.raises(ValueError, match="mutually exclusive"): | ||
| tts.update_options(voice="narrator", voice_id="abc") |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃煛 Explicit null selects the catalog voice
With
voice_id=Noneand novoice,TTSsubstitutes Harper's ID instead of omitting both selectors. The provider uses Harper rather than its model-default voice.Learn more
A Gradium setup message includes
voice_idonly when its stored value is notNonein ChunkedStream._run and SynthesizeStream._run_ws. Previously, passingvoice_id=Nonewith no name left both selectors absent, allowing the provider to choose its model voice. The new fallback treats an explicitNoneexactly like an omitted argument and inserts the catalog ID.Example: An agent constructs
TTS(api_key="...", voice_id=None)to use its deployed model voice. The setup now sendsvoice_id="4SZHfMpw-p46Ywgs"and selects Harper instead.Recommended fix: Distinguish an omitted
voice_idfrom explicitNoneusing a sentinel default, and applyDEFAULT_VOICE_IDonly for the omitted case whenvoiceis absent. Keep explicitNoneas an absent selector in both setup messages.Was this helpful? React with 馃憤 or 馃憥 to provide feedback.