Skip to content

fix: OpenAI TTS voice exclude unsupported voices based on the selecte…#1006

Open
milovate wants to merge 1 commit into
masterfrom
fix/openai-tts-voice-model-compat
Open

fix: OpenAI TTS voice exclude unsupported voices based on the selecte…#1006
milovate wants to merge 1 commit into
masterfrom
fix/openai-tts-voice-model-compat

Conversation

@milovate

@milovate milovate commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

…d model.

Q/A checklist

  • I have tested my UI changes on mobile and they look acceptable
  • I have tested changes to the workflows in both the API and the UI
  • I have done a code review of my changes and looked at each line of the diff + the references of each function I have changed
  • My changes have not increased the import time of the server
How to check import time?

time python -c 'import server'

You can visualize this using tuna:

python3 -X importtime -c 'import server' 2> out.log && tuna out.log

To measure import time for a specific library:

$ time python -c 'import pandas'

________________________________________________________
Executed in    1.15 secs    fish           external
   usr time    2.22 secs   86.00 micros    2.22 secs
   sys time    0.72 secs  613.00 micros    0.72 secs

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:

def my_function():
    import pandas as pd
    ...

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.


@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@milovate, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4449f4f1-67c1-4918-8868-8fb4c2dc3aae

📥 Commits

Reviewing files that changed from the base of the PR and between 0ff996c and cc0f77f.

📒 Files selected for processing (1)
  • daras_ai_v2/text_to_speech_settings_widgets.py
📝 Walkthrough

Walkthrough

This PR implements conditional voice filtering for OpenAI Text-to-Speech based on the selected model. A new helper method identifies GPT-4o-exclusive voices (ballad, verse), which the UI selector now uses to filter the voice dropdown when a non-gpt_4o_mini model is selected. The recipe's audio generation path was updated to read the model and voice from the state parameter with explicit defaults rather than from gui.session_state with fallback operators.

Suggested reviewers

  • devxpy
🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is truncated mid-word ('selecte…') and doesn't fully convey the main change about excluding unsupported voices based on the selected model. Complete the truncated title to clearly state the full objective, e.g., 'fix: Exclude unsupported OpenAI TTS voices based on selected model'
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The pull request description includes the required Q/A checklist and legal boilerplate template, but is missing a substantive description of the changes and rationale. Add a clear description explaining what was changed, why it was changed, and how it addresses the issue. The summary should describe the voice filtering logic and model compatibility changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@milovate milovate force-pushed the fix/openai-tts-voice-model-compat branch from 0ff996c to 8682b74 Compare June 12, 2026 18:39

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
daras_ai_v2/text_to_speech_settings_widgets.py (1)

79-81: ⚡ Quick win

Return a tuple instead of a set for type consistency.

The enum_selector function expects exclude: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4e38d2e and 0ff996c.

📒 Files selected for processing (2)
  • daras_ai_v2/text_to_speech_settings_widgets.py
  • recipes/TextToSpeech.py

@milovate milovate requested a review from devxpy June 12, 2026 18:47

@devxpy devxpy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
  • None grouped with gpt_4_o_mini fixes first-render hiding GPT-4o voices before model is set in settings
  • reusable later in TextToSpeech.run() for API validation

@milovate milovate force-pushed the fix/openai-tts-voice-model-compat branch 2 times, most recently from d4a8fe1 to f82d0c3 Compare June 13, 2026 11:44
- 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>
@milovate milovate force-pushed the fix/openai-tts-voice-model-compat branch from f82d0c3 to cc0f77f Compare June 13, 2026 11:46
@milovate milovate requested a review from devxpy June 13, 2026 11:46
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