Repository navigation
Conversation
The sync transcription server already returns a language_code field in every response, but SyncTranscriptResponse did not declare it, so the value was silently discarded by Pydantic. Add language_code: Optional[str] = None to surface the ISO 639-1 code the model used (e.g. "en", "es"). The field is Optional to stay backwards-compatible with server responses that predate the field. This is especially useful when language_codes is not set and the caller wants to confirm which language the model automatically detected. Add two unit tests following the existing request_time_ms pattern: - test_transcribe_parses_language_code (field present in server JSON) - test_transcribe_parses_response_without_language_code (field absent)
pylrn
force-pushed
the
feat/sync-response-language-code
branch
from
September 25, 2026 04:56
7233d92 to
3162496
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The sync transcription server already returns a
language_codefield in every response (ISO 639-1, e.g."en","es"), butSyncTranscriptResponsedid not declare it, so Pydantic silently discarded the value.This PR adds
language_code: Optional[str] = NonetoSyncTranscriptResponseso callers can inspect which language the model used — particularly useful whenlanguage_codeswas not set and automatic language detection was used.Changes
assemblyai/types.py— addlanguage_code: Optional[str] = NonetoSyncTranscriptResponsewith a full docstring.tests/unit/test_sync.py— two new unit tests following the existingrequest_time_mspattern:test_transcribe_parses_language_code— server returns the field → it is surfaced on the response object.test_transcribe_parses_response_without_language_code— server response predates the field →language_codeisNonewithout a parse failure.Backwards compatibility
The field is
Optionalwith aNonedefault, so existing code that does not use it continues to work unchanged.