Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assemblyai/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.6.1"
__version__ = "1.6.2"
7 changes: 7 additions & 0 deletions assemblyai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2908,6 +2908,13 @@ class SyncTranscriptResponse(BaseModel):
session_id: str
"Server-generated UUID for this request. Record it to correlate with support."

language_code: Optional[str] = None
"""ISO 639-1 language code the model used for this transcript (e.g. ``"en"``
for English, ``"es"`` for Spanish). Populated when the server detects or is
told the language; ``None`` for responses from servers that predate the field.
Useful when ``language_codes`` was not set and you need to know which language
the model chose."""

request_time_ms: Optional[float] = None
"""End-to-end server-side request time in milliseconds: queue wait, auth,
multipart parse, decode, inference, and serialization. ``None`` when the
Expand Down
34 changes: 34 additions & 0 deletions tests/unit/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,40 @@ def test_transcribe_parses_response_without_request_time(httpx_mock: HTTPXMock):
assert result.request_time_ms is None


def test_transcribe_parses_language_code(httpx_mock: HTTPXMock):
# Given a server response that includes the language_code field
response = {**_OK_RESPONSE, "language_code": "es"}
httpx_mock.add_response(
url=TRANSCRIBE_URL,
method="POST",
status_code=httpx.codes.OK,
json=response,
)

# When transcribing
result = aai.SyncTranscriber().transcribe(b"RIFFfake-wav-bytes")

# Then language_code is surfaced on the response
assert result.language_code == "es"


def test_transcribe_parses_response_without_language_code(httpx_mock: HTTPXMock):
# Given a server response that predates the language_code field
response = {k: v for k, v in _OK_RESPONSE.items() if k != "language_code"}
httpx_mock.add_response(
url=TRANSCRIBE_URL,
method="POST",
status_code=httpx.codes.OK,
json=response,
)

# When transcribing
result = aai.SyncTranscriber().transcribe(b"RIFFfake-wav-bytes")

# Then language_code is None instead of a parse failure
assert result.language_code is None


def test_transcribe_sends_model_header_and_wav_part(httpx_mock: HTTPXMock):
# Given a mocked sync endpoint
_mock_ok(httpx_mock)
Expand Down
Loading