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
6 changes: 6 additions & 0 deletions assemblyai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,12 @@ class SpeakerOptions(BaseModel):
None,
description="Enable or disable two-stage clustering for speaker diarization",
)
short_file_diarization_method: Optional[
Literal["deliberate", "balanced", "conservative", "aggressive"]
] = Field(
None,
description="Diarization method for short files. Options: deliberate (default), balanced, conservative, aggressive",
)
long_file_diarization_method: Optional[Literal["standard", "experimental"]] = Field(
None,
description="Diarization method for long files. Options: standard (default), experimental",
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/test_speaker_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,30 @@ def test_transcription_config_with_two_stage_clustering():
assert config.speaker_options.use_two_stage_clustering is False


def test_speaker_options_short_file_diarization_method():
"""Test that SpeakerOptions can be created with short_file_diarization_method."""
speaker_options = aai.SpeakerOptions(short_file_diarization_method="deliberate")
assert speaker_options.short_file_diarization_method == "deliberate"


def test_speaker_options_short_file_diarization_all_methods():
"""Test all valid values for short_file_diarization_method."""
methods = ["deliberate", "balanced", "conservative", "aggressive"]
for method in methods:
speaker_options = aai.SpeakerOptions(short_file_diarization_method=method)
assert speaker_options.short_file_diarization_method == method


def test_speaker_options_with_diarization_methods():
"""Test that SpeakerOptions can be created with both diarization methods."""
speaker_options = aai.SpeakerOptions(
short_file_diarization_method="balanced",
long_file_diarization_method="experimental",
)
assert speaker_options.short_file_diarization_method == "balanced"
assert speaker_options.long_file_diarization_method == "experimental"


def test_speaker_options_long_file_diarization_method():
"""Test that SpeakerOptions can be created with long_file_diarization_method."""
speaker_options = aai.SpeakerOptions(long_file_diarization_method="experimental")
Expand Down Expand Up @@ -164,6 +188,7 @@ def test_transcription_config_with_all_speaker_options():
min_speakers_expected=2,
max_speakers_expected=5,
use_two_stage_clustering=False,
short_file_diarization_method="conservative",
long_file_diarization_method="experimental",
)

Expand All @@ -175,4 +200,5 @@ def test_transcription_config_with_all_speaker_options():
assert config.speaker_options.min_speakers_expected == 2
assert config.speaker_options.max_speakers_expected == 5
assert config.speaker_options.use_two_stage_clustering is False
assert config.speaker_options.short_file_diarization_method == "conservative"
assert config.speaker_options.long_file_diarization_method == "experimental"
Loading