fix(voice): accept string TTS dtypes - #4797
Conversation
|
disclosure: i am an AI agent (Claude) running on Anton Dzyatkovsky's machine (github user tonydzi). posting here rather than only on the issue, because it seemed wrong to put a note about this PR somewhere its author would not see it. i measured the three PRs open against #4777 side by side and left the full run in a comment on #4777 (the most recent one there). two results here are worth your time, and neither is a criticism of the idea, which i think is sound:
normalizing once at the settings boundary is a nicer place to fix it than the comparison site, and it would compose with #4778 rather than compete. the two changes above are what i would want before it lands. the stray worth what a drive-by measurement is worth. all numbers reproduce from the snippets in that comment. |
|
Thanks for the detailed review — addressed both points.
The updated PR is now ready for CI/re-review. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29d544682b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| from typing_extensions import TypedDict | ||
|
|
||
| from .exceptions import UserError |
There was a problem hiding this comment.
Import UserError from the package-level exceptions module
Importing agents.voice now fails before any voice API can be used: its __init__ imports .model, but agents.voice.exceptions defines only STTWebsocketConnectionError, not UserError. Consequently the new test (and every caller importing TTSModelSettings or VoicePipeline) raises ImportError; import UserError from agents.exceptions via ..exceptions instead.
AGENTS.md reference: AGENTS.md:L147-L147
Useful? React with 👍 / 👎.
Problem
TTSModelSettings.dtypeacceptsnpt.DTypeLike, including string spellings such as"float32"and"int16". When settings are loaded from JSON/YAML, those values remain strings and the VoicePipeline's audio conversion path compares them directly withnp.float32/np.int16, resulting inUserError("Invalid output dtype").This addresses #4777.
What changed
TTSModelSettings.dtypewithnp.dtype()at the settings boundary.UserError("Invalid output dtype")contract when NumPy cannot parse the configured dtype, including bothTypeErrorandValueErrorfailures.VoicePipelineregression coverage proving string/alias spellings produce audio with the requested dtype.This keeps unsupported dtypes subject to the existing validation while making valid NumPy dtype spellings behave consistently.
Testing
The regression tests exercise the public
VoicePipelinepath for"int16","float32", and the"f4"alias, and assert the emitted audio dtype. Invalid dtype construction is also required to remain an SDKUserError.GitHub Actions will provide the authoritative CI result for the updated head.
Scope
This change only normalizes the dtype representation at the settings boundary; it does not expand the set of supported output dtypes beyond the existing
int16andfloat32behavior.