Skip to content

feat(types): expose language_code in SyncTranscriptResponse - #257

Open
pylrn wants to merge 2 commits into
AssemblyAI:masterfrom
pylrn:feat/sync-response-language-code
Open

pylrn wants to merge 2 commits into
AssemblyAI:masterfrom
pylrn:feat/sync-response-language-code

Conversation

@pylrn

@pylrn pylrn commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Summary

The sync transcription server already returns a language_code field in every response (ISO 639-1, e.g. "en", "es"), but SyncTranscriptResponse did not declare it, so Pydantic silently discarded the value.

This PR adds language_code: Optional[str] = None to SyncTranscriptResponse so callers can inspect which language the model used — particularly useful when language_codes was not set and automatic language detection was used.

Changes

  • assemblyai/types.py — add language_code: Optional[str] = None to SyncTranscriptResponse with a full docstring.
  • tests/unit/test_sync.py — two new unit tests following the existing request_time_ms pattern:
    • 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_code is None without a parse failure.

Backwards compatibility

The field is Optional with a None default, so existing code that does not use it continues to work unchanged.

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
pylrn force-pushed the feat/sync-response-language-code branch from 7233d92 to 3162496 Compare September 25, 2026 04:56
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.

1 participant