Class RealtimeEventReceiver
Inherited Members
Namespace: Glitch9.AIDevKit.OpenAI.Realtime
Assembly: .dll
Syntax
public class RealtimeEventReceiver : RealtimeEventReceiverBase
Constructors
RealtimeEventReceiver(RealtimeSessionController, Action<float[]>, Action<float[]>, Action<AudioClip>, Action<string>, Action<string>, Action<string>, Action<string>, Action<string>, Action<ErrorResponse>, Action<string>, Action<RealtimeItemStatus>, FunctionManager, bool, bool)
Declaration
public RealtimeEventReceiver(RealtimeSessionController controller, Action<float[]> onReceiveAudioDelta, Action<float[]> onReceiveAudioDeltaDone, Action<AudioClip> onReceiveAudioClip, Action<string> onReceiveTextDelta, Action<string> onReceiveTextDeltaDone, Action<string> onReceiveTranscriptDelta, Action<string> onReceiveTranscriptDeltaDone, Action<string> onReceiveInputTranscriptionSuccess, Action<ErrorResponse> onReceiveInputTranscriptionFailed, Action<string> onSessionStateChanged, Action<RealtimeItemStatus> onItemStatusChanged, FunctionManager functionManager, bool audioEnabled, bool transcriptEnabled)
Parameters
Type | Name | Description |
---|---|---|
RealtimeSessionController | controller | |
Action<float[]> | onReceiveAudioDelta | |
Action<float[]> | onReceiveAudioDeltaDone | |
Action<AudioClip> | onReceiveAudioClip | |
Action<string> | onReceiveTextDelta | |
Action<string> | onReceiveTextDeltaDone | |
Action<string> | onReceiveTranscriptDelta | |
Action<string> | onReceiveTranscriptDeltaDone | |
Action<string> | onReceiveInputTranscriptionSuccess | |
Action<ErrorResponse> | onReceiveInputTranscriptionFailed | |
Action<string> | onSessionStateChanged | |
Action<RealtimeItemStatus> | onItemStatusChanged | |
FunctionManager | functionManager | |
bool | audioEnabled | |
bool | transcriptEnabled |
Properties
AudioEnabled
Declaration
public bool AudioEnabled { get; set; }
Property Value
Type | Description |
---|---|
bool |
TranscriptEnabled
Declaration
public bool TranscriptEnabled { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
OnConversationItemInputAudioTranscriptionCompleted(string, int?, string)
Returned when input audio transcription is enabled and a transcription succeeds.
Declaration
public override void OnConversationItemInputAudioTranscriptionCompleted(string eventId, int? contentIndex, string transcription)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
int? | contentIndex | The index of the content part containing the audio. |
string | transcription | The transcribed text. |
Overrides
OnConversationItemInputAudioTranscriptionFailed(string, int?, ErrorResponse)
Returned when input audio transcription is configured, and a transcription request for a user message failed.
Declaration
public override void OnConversationItemInputAudioTranscriptionFailed(string eventId, int? contentIndex, ErrorResponse error)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
int? | contentIndex | The index of the content part containing the audio. |
ErrorResponse | error | Details of the transcription error. |
Overrides
OnResponseAudioDelta(string, string, string, int?, int?, string)
Returned when the model-generated audio is updated.
Declaration
public override void OnResponseAudioDelta(string eventId, string responseId, string itemId, int? outputIndex, int? contentIndex, string delta)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
string | responseId | The ID of the response. |
string | itemId | The ID of the item. |
int? | outputIndex | The index of the output item in the response. |
int? | contentIndex | The index of the content part in the item's content array. |
string | delta | Base64-encoded audio data delta. |
Overrides
OnResponseAudioDone(string, string, string, int?, int?)
Returned when the model-generated audio is done.
Declaration
public override void OnResponseAudioDone(string eventId, string responseId, string itemId, int? outputIndex, int? contentIndex)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
string | responseId | The ID of the response. |
string | itemId | The ID of the item. |
int? | outputIndex | The index of the output item in the response. |
int? | contentIndex | The index of the content part in the item's content array. |
Overrides
OnResponseAudioTranscriptDelta(string, string, string, int?, int?, string)
Returned when the model-generated transcription of audio output is updated.
Declaration
public override void OnResponseAudioTranscriptDelta(string eventId, string responseId, string itemId, int? outputIndex, int? contentIndex, string delta)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
string | responseId | The ID of the response. |
string | itemId | The ID of the item. |
int? | outputIndex | The index of the output item in the response. |
int? | contentIndex | The index of the content part in the item's content array. |
string | delta | The transcript delta. |
Overrides
OnResponseAudioTranscriptDone(string, string, string, int?, int?, string)
Returned when the model-generated transcription of audio output is done streaming.
Declaration
public override void OnResponseAudioTranscriptDone(string eventId, string responseId, string itemId, int? outputIndex, int? contentIndex, string transcript)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
string | responseId | The ID of the response. |
string | itemId | The ID of the item. |
int? | outputIndex | The index of the output item in the response. |
int? | contentIndex | The index of the content part in the item's content array. |
string | transcript | The final transcript of the audio. |
Overrides
OnResponseContentPartAdded(string, string, string, int?, int?, RealtimeItemContent)
Returned when a new content part is added to an assistant message item during response generation.
Declaration
public override void OnResponseContentPartAdded(string eventId, string responseId, string itemId, int? itemIndex, int? contentIndex, RealtimeItemContent part)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
string | responseId | The ID of the response. |
string | itemId | The ID of the item to which the content part was added. |
int? | itemIndex | |
int? | contentIndex | The index of the content part in the item's content array. |
RealtimeItemContent | part | The added content part. |
Overrides
OnResponseCreated(string, RealtimeItem)
Returned when a new Response is created.
Declaration
public override void OnResponseCreated(string eventId, RealtimeItem response)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
RealtimeItem | response | The response resource. |
Overrides
OnResponseDone(string, RealtimeItem)
Returned when a Response is done streaming. Always emitted, no matter the final state.
Declaration
public override void OnResponseDone(string eventId, RealtimeItem item)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
RealtimeItem | item |
Overrides
OnResponseOutputItemAdded(string, string, int?, RealtimeItem)
Returned when a new Item is created during response generation.
Declaration
public override void OnResponseOutputItemAdded(string eventId, string responseId, int? itemIndex, RealtimeItem item)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
string | responseId | The ID of the response to which the item belongs. |
int? | itemIndex | |
RealtimeItem | item | The created item. |
Overrides
OnResponseTextDelta(string, string, string, int?, int?, string)
Returned when the text value of a "text" content part is updated.
Declaration
public override void OnResponseTextDelta(string eventId, string responseId, string itemId, int? outputIndex, int? contentIndex, string delta)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
string | responseId | The ID of the response. |
string | itemId | The ID of the item. |
int? | outputIndex | The index of the output item in the response. |
int? | contentIndex | The index of the content part in the item's content array. |
string | delta | The text delta. |
Overrides
OnResponseTextDone(string, string, string, int?, int?, string)
Returned when the text value of a "text" content part is done streaming.
Declaration
public override void OnResponseTextDone(string eventId, string responseId, string itemId, int? outputIndex, int? contentIndex, string text)
Parameters
Type | Name | Description |
---|---|---|
string | eventId | The unique ID of the event. |
string | responseId | The ID of the response. |
string | itemId | The ID of the item. |
int? | outputIndex | The index of the output item in the response. |
int? | contentIndex | The index of the content part in the item's content array. |
string | text | The final text content. |