Skip to content

Commit 15c932f

Browse files
glyuckm1guelpf
authored andcommitted
Add output_audio_buffer.started and output_audio_buffer.stopped server events
These are sent in WebRTC mode and the WebRTCConnector throws a decode error when receives them
1 parent abd17ea commit 15c932f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Models/ServerEvent.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ public enum ServerEvent: Sendable {
119119
public let itemId: String
120120
}
121121

122+
public struct OutputAudioBufferStartedEvent: Decodable, Sendable {
123+
/// The unique ID of the server event.
124+
public let eventId: String
125+
/// The ID of the response.
126+
public let responseId: String
127+
}
128+
129+
public struct OutputAudioBufferStoppedEvent: Decodable, Sendable {
130+
/// The unique ID of the server event.
131+
public let eventId: String
132+
/// The ID of the response.
133+
public let responseId: String
134+
}
135+
122136
public struct ResponseEvent: Decodable, Sendable {
123137
/// The unique ID of the server event.
124138
public let eventId: String
@@ -342,6 +356,10 @@ public enum ServerEvent: Sendable {
342356
case conversationItemTruncated(ConversationItemTruncatedEvent)
343357
/// Returned when an item in the conversation is deleted.
344358
case conversationItemDeleted(ConversationItemDeletedEvent)
359+
/// Returned when the output audio buffer is started.
360+
case outputAudioBufferStarted(OutputAudioBufferStartedEvent)
361+
/// Returned when the output audio buffer is stopped.
362+
case outputAudioBufferStopped(OutputAudioBufferStoppedEvent)
345363
/// Returned when a new Response is created. The first event of response creation, where the response is in an initial state of "in_progress".
346364
case responseCreated(ResponseEvent)
347365
/// Returned when a Response is done streaming. Always emitted, no matter the final state.
@@ -405,6 +423,10 @@ extension ServerEvent: Identifiable {
405423
return event.eventId
406424
case let .conversationItemDeleted(event):
407425
return event.eventId
426+
case let .outputAudioBufferStarted(event):
427+
return event.eventId
428+
case let .outputAudioBufferStopped(event):
429+
return event.eventId
408430
case let .responseCreated(event):
409431
return event.eventId
410432
case let .responseDone(event):
@@ -477,6 +499,10 @@ extension ServerEvent: Decodable {
477499
self = try .conversationItemTruncated(ConversationItemTruncatedEvent(from: decoder))
478500
case "conversation.item.deleted":
479501
self = try .conversationItemDeleted(ConversationItemDeletedEvent(from: decoder))
502+
case "output_audio_buffer.started":
503+
self = try .outputAudioBufferStarted(OutputAudioBufferStartedEvent(from: decoder))
504+
case "output_audio_buffer.stopped":
505+
self = try .outputAudioBufferStopped(OutputAudioBufferStoppedEvent(from: decoder))
480506
case "response.created":
481507
self = try .responseCreated(ResponseEvent(from: decoder))
482508
case "response.done":

0 commit comments

Comments
 (0)