diff --git a/sdk/batch/speechmatics/batch/__init__.py b/sdk/batch/speechmatics/batch/__init__.py index 882bd33..cf12e86 100644 --- a/sdk/batch/speechmatics/batch/__init__.py +++ b/sdk/batch/speechmatics/batch/__init__.py @@ -27,6 +27,7 @@ from ._models import OperatingPoint from ._models import OutputConfig from ._models import SentimentAnalysisConfig +from ._models import SpeakerIdentifier from ._models import SummarizationConfig from ._models import TopicDetectionConfig from ._models import Transcript @@ -61,6 +62,7 @@ "OperatingPoint", "OutputConfig", "SentimentAnalysisConfig", + "SpeakerIdentifier", "StaticKeyAuth", "SummarizationConfig", "TimeoutError", diff --git a/sdk/batch/speechmatics/batch/_models.py b/sdk/batch/speechmatics/batch/_models.py index c375d34..56dcfcc 100644 --- a/sdk/batch/speechmatics/batch/_models.py +++ b/sdk/batch/speechmatics/batch/_models.py @@ -688,6 +688,22 @@ def from_dict(cls, data: dict[str, Any]) -> RecognitionResult: ) +@dataclass +class SpeakerIdentifier: + """A unique speaker detected in the transcript.""" + + label: str + speaker_identifiers: list[str] + + @classmethod + def from_dict(cls, data: dict[str, Any]) -> SpeakerIdentifier: + """Create SpeakerIdentifier from dictionary.""" + return cls( + label=data["label"], + speaker_identifiers=data["speaker_identifiers"], + ) + + @dataclass class Transcript: """ @@ -701,6 +717,7 @@ class Transcript: job: Job information and metadata. metadata: Recognition process metadata. results: List of recognition results with timing and alternatives. + speakers: List of unique speakers detected in the transcript, each with a label and byte identifiers. translations: Optional translations by language code. summary: Optional transcript summarization. sentiment_analysis: Optional sentiment analysis results. @@ -714,6 +731,7 @@ class Transcript: job: JobInfo metadata: RecognitionMetadata results: list[RecognitionResult] + speakers: Optional[list[SpeakerIdentifier]] = None translations: Optional[dict[str, Any]] = None summary: Optional[dict[str, Any]] = None sentiment_analysis: Optional[dict[str, Any]] = None @@ -839,11 +857,15 @@ def from_dict(cls, data: dict[str, Any]) -> Transcript: results_data = data.get("results", []) results = [RecognitionResult.from_dict(result) for result in results_data] + speakers_data = data.get("speakers") + speakers = [SpeakerIdentifier.from_dict(s) for s in speakers_data] if speakers_data else None + return cls( format=data["format"], job=job_info, metadata=metadata, results=results, + speakers=speakers, translations=data.get("translations"), summary=data.get("summary"), sentiment_analysis=data.get("sentiment_analysis"),