Add output.audio.played message handling and update documentation

- Introduced `output.audio.played` message type for client acknowledgment of audio playback completion.
- Updated `DuplexPipeline` to track client playback state and handle playback completion events.
- Enhanced session handling to route `output.audio.played` messages to the pipeline.
- Revised API documentation to include details about the new message type and its fields.
- Updated schema documentation to reflect the addition of `output.audio.played` in the message flow.
This commit is contained in:
Xin Wang
2026-03-04 10:01:34 +08:00
parent 80fff09b76
commit 7d4af18815
8 changed files with 275 additions and 19 deletions

View File

@@ -45,6 +45,15 @@ class ResponseCancelMessage(_StrictModel):
graceful: bool = False
class OutputAudioPlayedMessage(_StrictModel):
type: Literal["output.audio.played"]
tts_id: str = Field(..., min_length=1)
response_id: Optional[str] = None
turn_id: Optional[str] = None
played_at_ms: Optional[int] = Field(default=None, ge=0)
played_ms: Optional[int] = Field(default=None, ge=0)
class ToolCallResultStatus(_StrictModel):
code: int
message: str
@@ -67,6 +76,7 @@ CLIENT_MESSAGE_TYPES = {
"session.stop": SessionStopMessage,
"input.text": InputTextMessage,
"response.cancel": ResponseCancelMessage,
"output.audio.played": OutputAudioPlayedMessage,
"tool_call.results": ToolCallResultsMessage,
}