Skip to content

Commit 9f7f5df

Browse files
he-jamesAssemblyAI
andauthored
chore: sync sdk code with DeepLearning repo (#142)
Co-authored-by: AssemblyAI <engineering.sdk@assemblyai.com>
1 parent a53d113 commit 9f7f5df

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

assemblyai/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.45.1"
1+
__version__ = "0.45.2"

assemblyai/types.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,9 @@ class RawTranscriptionConfig(BaseModel):
668668
keyterms_prompt: Optional[List[str]] = None
669669
"The list of key terms used to generate the transcript with the Slam-1 speech model. Can't be used together with `prompt`."
670670

671+
language_codes: Optional[List[Union[str, LanguageCode]]] = None
672+
"List of language codes detected in the audio file when language detection is enabled"
673+
671674
model_config = ConfigDict(extra="allow")
672675

673676

@@ -1237,6 +1240,12 @@ def speech_threshold(self, threshold: Optional[float]) -> None:
12371240

12381241
self._raw_transcription_config.speech_threshold = threshold
12391242

1243+
@property
1244+
def language_codes(self) -> Optional[List[Union[str, LanguageCode]]]:
1245+
"Returns the list of language codes detected in the audio file when language detection is enabled."
1246+
1247+
return self._raw_transcription_config.language_codes
1248+
12401249
# endregion
12411250

12421251
# region: Convenience (helper) methods
@@ -1913,6 +1922,9 @@ class BaseTranscript(BaseModel):
19131922
language_confidence: Optional[float] = None
19141923
"The confidence score for the detected language, between 0.0 (low confidence) and 1.0 (high confidence)."
19151924

1925+
language_codes: Optional[List[Union[str, LanguageCode]]] = None
1926+
"List of language codes detected in the audio file when language detection is enabled"
1927+
19161928
speech_threshold: Optional[float] = None
19171929
"Reject audio files that contain less than this fraction of speech. Valid values are in the range [0,1] inclusive"
19181930

tests/unit/test_transcript.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,17 @@ def test_delete_by_id_async(httpx_mock: HTTPXMock):
452452
assert transcript.audio_url == mock_transcript_response["audio_url"]
453453

454454

455+
def test_language_codes_field():
456+
"""Test language_codes field deserialization"""
457+
mock_response = factories.generate_dict_factory(
458+
factories.TranscriptCompletedResponseFactory
459+
)()
460+
mock_response["language_codes"] = ["en", "es"]
461+
462+
response = aai.types.TranscriptResponse(**mock_response)
463+
assert response.language_codes == ["en", "es"]
464+
465+
455466
def test_speech_model_used_field_deserialization():
456467
"""
457468
Tests that the speech_model_used field can be properly deserialized.

0 commit comments

Comments
 (0)