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__ = "0.64.32"
__version__ = "0.64.33"
4 changes: 4 additions & 0 deletions assemblyai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2259,6 +2259,8 @@ class SentencesResponse(BaseModel):
sentences: List[Sentence]
confidence: float
audio_duration: float
speech_model_used: Optional[str] = None
"The actual speech model that was used for the transcription"


class Paragraph(Word):
Expand All @@ -2273,6 +2275,8 @@ class ParagraphsResponse(BaseModel):
paragraphs: List[Paragraph]
confidence: float
audio_duration: float
speech_model_used: Optional[str] = None
"The actual speech model that was used for the transcription"


class BaseTranscript(BaseModel):
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ class Meta:
sentences = factory.List([factory.SubFactory(SentenceFactory)])
confidence = factory.Faker("pyfloat", min_value=0.0, max_value=1.0)
audio_duration = factory.Faker("pyint")
speech_model_used = "universal-2"


class ParagraphsResponseFactory(factory.Factory):
Expand All @@ -448,6 +449,7 @@ class Meta:
paragraphs = factory.List([factory.SubFactory(ParagraphFactory)])
confidence = factory.Faker("pyfloat", min_value=0.0, max_value=1.0)
audio_duration = factory.Faker("pyint")
speech_model_used = "universal-2"


def generate_dict_factory(f: factory.Factory) -> Callable[[], Dict[str, Any]]:
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/test_transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,24 @@ def compare_words(lhs: List[aai.Word], rhs: List[Dict[str, Any]]) -> bool:
assert len(httpx_mock.get_requests()) == 2


def test_sentences_and_paragraphs_parse_speech_model_used():
"""
Tests that speech_model_used is parsed on the sentences and paragraphs responses.
"""
mock_sentences_response = factories.generate_dict_factory(
factories.SentencesResponseFactory
)()
mock_paragraphs_response = factories.generate_dict_factory(
factories.ParagraphsResponseFactory
)()

sentences_response = aai.types.SentencesResponse(**mock_sentences_response)
paragraphs_response = aai.types.ParagraphsResponse(**mock_paragraphs_response)

assert sentences_response.speech_model_used == "universal-2"
assert paragraphs_response.speech_model_used == "universal-2"


def test_get_sentences_and_paragraphs_fails(httpx_mock: HTTPXMock):
"""
Tests whether getting sentences and paragraphs fails.
Expand Down