Codex.Voice.Events (Codex SDK v0.7.2)

Copy Markdown View Source

Voice stream event types for the voice pipeline.

These events are emitted by the VoicePipeline during voice processing:

  • VoiceStreamEventAudio - Audio data from the pipeline
  • VoiceStreamEventLifecycle - Lifecycle events (turn started/ended, session ended)
  • VoiceStreamEventError - Error events

Example

for event <- VoicePipeline.stream(input) do
  case event do
    %VoiceStreamEventAudio{data: data} ->
      play_audio(data)

    %VoiceStreamEventLifecycle{event: :turn_ended} ->
      IO.puts("Turn ended")

    %VoiceStreamEventError{error: error} ->
      Logger.error("Voice error: #{inspect(error)}")
  end
end

Summary

Types

t()

A voice stream event from the pipeline.

Functions

Create an audio event.

Create an error event.

Create a lifecycle event.

Types

Functions

audio(data)

Create an audio event.

Examples

iex> event = Codex.Voice.Events.audio(<<1, 2, 3>>)
iex> event.type
:voice_stream_event_audio
iex> event.data
<<1, 2, 3>>

error(exception)

Create an error event.

Examples

iex> error = %RuntimeError{message: "test"}
iex> event = Codex.Voice.Events.error(error)
iex> event.type
:voice_stream_event_error

lifecycle(event)

Create a lifecycle event.

Examples

iex> event = Codex.Voice.Events.lifecycle(:turn_ended)
iex> event.type
:voice_stream_event_lifecycle
iex> event.event
:turn_ended