Skip to content

feat(async): Improve Speech Understanding UX Through TranscriptConfig - #252

Merged
dmorrissey-aai merged 5 commits into
masterfrom
dmorrissey/speech_understanding_ux
Sep 11, 2026
Merged

dmorrissey-aai merged 5 commits into
masterfrom
dmorrissey/speech_understanding_ux

Conversation

@dmorrissey-aai

Copy link
Copy Markdown
Contributor

Adjust pydantic models to allow for direct dictionary construction with validation.

What

Before:

    return aai.TranscriptionConfig(
        speech_understanding=aai.SpeechUnderstandingRequest(
            request=aai.SpeechUnderstandingFeatureRequests(
                speaker_identification=aai.SpeakerIdentificationRequest(
                    speaker_type=aai.SpeakerType.name,
                    known_values=["Michel Martin", "Peter DeCarlo"],
                )
            )
        )
    )

After:

    config = aai.TranscriptionConfig()
    config.speech_understanding = {
        "request": {
            "speaker_identification": {
                "speaker_type": "name",
                "known_values": ["Michel Martin", "Peter DeCarlo"],
            }
        }
    }
    return config

OR

    return aai.TranscriptionConfig(
        speech_understanding={
            "request": {
                "speaker_identification": {
                    "speaker_type": "name",
                    "known_values": ["Michel Martin", "Peter DeCarlo"],
                }
            }
        }
    )

Why

Screenshot 2026-09-11 at 8 55 01 AM

Broad criticism of the UX of the python sdk, with the hope of reducing new user friction.

How

By typing each attribute as Union[TypedClass, dict[str, Any]] and setting validate_assignment=True, construction and assignment of the attributes can now be made via dict passthrough while retaining actual strictness.

Existing schema, construction and assignment style still work.

Tests

New tests added proving dict pass through works and retains parity with the class-style construction

dmorrissey-aai and others added 2 commits September 11, 2026 10:48
mypy resolves assignment through a property using the getter's type, so
the dict-accepting setters need an ignore at the __init__ call sites.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dmorrissey-aai
dmorrissey-aai merged commit 8fd216b into master Sep 11, 2026
8 checks passed
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