fix: OpenAI TTS voice exclude unsupported voices based on the selecte…#1006
fix: OpenAI TTS voice exclude unsupported voices based on the selecte…#1006milovate wants to merge 1 commit into
Conversation
|
Warning Review limit reached
More reviews will be available in 39 minutes and 41 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR implements conditional voice filtering for OpenAI Text-to-Speech based on the selected model. A new helper method identifies GPT-4o-exclusive voices ( Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
0ff996c to
8682b74
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
daras_ai_v2/text_to_speech_settings_widgets.py (1)
79-81: ⚡ Quick winReturn a tuple instead of a set for type consistency.
The
enum_selectorfunction expectsexclude: list[E] | None(see context snippet 3), but this helper returns a set. While it works at runtime due to duck typing, a tuple would match the expected iterable type and improve type safety.♻️ Proposed fix
`@classmethod` def _gpt4o_supported_voices(cls): - return {cls.ballad, cls.verse} + return (cls.ballad, cls.verse)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@daras_ai_v2/text_to_speech_settings_widgets.py` around lines 79 - 81, The helper method _gpt4o_supported_voices currently returns a set but should return a tuple to match the expected iterable type used by enum_selector's exclude parameter; change the return value of _gpt4o_supported_voices to return a tuple containing cls.ballad and cls.verse so callers like enum_selector(..., exclude=...) receive a tuple instead of a set and maintain type consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@daras_ai_v2/text_to_speech_settings_widgets.py`:
- Around line 79-81: The helper method _gpt4o_supported_voices currently returns
a set but should return a tuple to match the expected iterable type used by
enum_selector's exclude parameter; change the return value of
_gpt4o_supported_voices to return a tuple containing cls.ballad and cls.verse so
callers like enum_selector(..., exclude=...) receive a tuple instead of a set
and maintain type consistency.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5b0ad01c-8e4d-4a45-b35c-0fc94bdd4589
📒 Files selected for processing (2)
daras_ai_v2/text_to_speech_settings_widgets.pyrecipes/TextToSpeech.py
devxpy
left a comment
There was a problem hiding this comment.
@milovate Small refactor suggestion — instead of _gpt4o_supported_voices() + exclude= in openai_tts_selector, consider a supported_voices(model_name) classmethod on OpenAI_TTS_Voices and build the selectbox from that list directly.
@classmethod
def supported_voices(cls, model_name: str | None = None):
model = OpenAI_TTS_Models.get(model_name)
match model:
case OpenAI_TTS_Models.gpt_4_o_mini | None:
return list(cls)
case _:
return list(set(cls) - {cls.ballad, cls.verse, cls.marin, cls.cedar})def openai_tts_selector():
model_name = gui.session_state.get("openai_tts_model")
voices = OpenAI_TTS_Voices.supported_voices(model_name)
options = {voice.name: voice.label for voice in voices}
gui.selectbox(
label="###### OpenAI Voice Name",
key="openai_voice_name",
options=list(options),
format_func=options.__getitem__,
)Benefits:
- positive API ("what voices are supported?") instead of inverted exclude logic
Nonegrouped withgpt_4_o_minifixes first-render hiding GPT-4o voices before model is set in settings- reusable later in
TextToSpeech.run()for API validation
d4a8fe1 to
f82d0c3
Compare
- Ballad, Verse, Marin, and Cedar are GPT-4o-mini-tts-only voices, but the old enum_selector exclude path did not scale cleanly as new GPT-4o-only voices were added. - Add Marin and Cedar voices and replace exclude logic with OpenAI_TTS_Voices.supported_voices(), which gui.selectbox uses to show only compatible voices for the active model. Co-authored-by: Cursor <cursoragent@cursor.com>
f82d0c3 to
cc0f77f
Compare
…d model.
Q/A checklist
How to check import time?
You can visualize this using tuna:
To measure import time for a specific library:
To reduce import times, import libraries that take a long time inside the functions that use them instead of at the top of the file:
Legal Boilerplate
Look, I get it. The entity doing business as “Gooey.AI” and/or “Dara.network” was incorporated in the State of Delaware in 2020 as Dara Network Inc. and is gonna need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Dara Network Inc can use, modify, copy, and redistribute my contributions, under its choice of terms.