Skip to content
Merged
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.54.0"
__version__ = "0.54.1"
2 changes: 2 additions & 0 deletions assemblyai/streaming/v3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
EventMessage,
LLMGatewayResponseEvent,
SpeechModel,
SpeechStartedEvent,
StreamingClientOptions,
StreamingError,
StreamingEvents,
Expand All @@ -21,6 +22,7 @@
"EventMessage",
"LLMGatewayResponseEvent",
"SpeechModel",
"SpeechStartedEvent",
"StreamingClient",
"StreamingClientOptions",
"StreamingError",
Expand Down
3 changes: 3 additions & 0 deletions assemblyai/streaming/v3/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ForceEndpoint,
LLMGatewayResponseEvent,
OperationMessage,
SpeechStartedEvent,
StreamingClientOptions,
StreamingError,
StreamingErrorCodes,
Expand Down Expand Up @@ -236,6 +237,8 @@ def _parse_message(self, data: Dict[str, Any]) -> Optional[EventMessage]:
return TerminationEvent.model_validate(data)
elif event_type == StreamingEvents.Turn:
return TurnEvent.model_validate(data)
elif event_type == StreamingEvents.SpeechStarted:
return SpeechStartedEvent.model_validate(data)
elif event_type == StreamingEvents.LLMGatewayResponse:
return LLMGatewayResponseEvent.model_validate(data)
else:
Expand Down
7 changes: 7 additions & 0 deletions assemblyai/streaming/v3/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class TerminationEvent(BaseModel):
session_duration_seconds: Optional[int] = None


class SpeechStartedEvent(BaseModel):
type: Literal["SpeechStarted"] = "SpeechStarted"
timestamp: int


class ErrorEvent(BaseModel):
error: str

Expand All @@ -64,6 +69,7 @@ class LLMGatewayResponseEvent(BaseModel):
BeginEvent,
TerminationEvent,
TurnEvent,
SpeechStartedEvent,
ErrorEvent,
LLMGatewayResponseEvent,
]
Expand Down Expand Up @@ -175,5 +181,6 @@ class StreamingEvents(Enum):
Begin = "Begin"
Termination = "Termination"
Turn = "Turn"
SpeechStarted = "SpeechStarted"
Error = "Error"
LLMGatewayResponse = "LLMGatewayResponse"
12 changes: 12 additions & 0 deletions tests/unit/test_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from assemblyai.streaming.v3 import (
SpeechModel,
SpeechStartedEvent,
StreamingClient,
StreamingClientOptions,
StreamingParameters,
Expand Down Expand Up @@ -352,3 +353,14 @@ def test_turn_event_without_speaker_label():
}
event = TurnEvent.parse_obj(data)
assert event.speaker_label is None


def test_speech_started_event():
"""Test SpeechStarted event parsing (u3-rt-pro only)"""
data = {
"type": "SpeechStarted",
"timestamp": 1280,
}
event = SpeechStartedEvent.parse_obj(data)
assert event.type == "SpeechStarted"
assert event.timestamp == 1280