跳过内容

Events

VoiceStreamEvent module-attribute

VoiceStreamEvent: TypeAlias = Union[
    VoiceStreamEventAudio,
    VoiceStreamEventLifecycle,
    VoiceStreamEventError,
]

来自 VoicePipeline 的事件,通过 StreamedAudioResult.stream() 流式传输。

VoiceStreamEventAudio dataclass

来自 VoicePipeline 的流式事件

源代码位于 src/agents/voice/events.py
@dataclass
class VoiceStreamEventAudio:
    """Streaming event from the VoicePipeline"""

    data: npt.NDArray[np.int16 | np.float32] | None
    """The audio data."""

    type: Literal["voice_stream_event_audio"] = "voice_stream_event_audio"
    """The type of event."""

data instance-attribute

data: NDArray[int16 | float32] | None

音频数据。

type class-attribute instance-attribute

type: Literal["voice_stream_event_audio"] = (
    "voice_stream_event_audio"
)

事件类型。

VoiceStreamEventLifecycle dataclass

来自 VoicePipeline 的流式事件

源代码位于 src/agents/voice/events.py
@dataclass
class VoiceStreamEventLifecycle:
    """Streaming event from the VoicePipeline"""

    event: Literal["turn_started", "turn_ended", "session_ended"]
    """The event that occurred."""

    type: Literal["voice_stream_event_lifecycle"] = "voice_stream_event_lifecycle"
    """The type of event."""

event instance-attribute

event: Literal[
    "turn_started", "turn_ended", "session_ended"
]

发生的事件。

type class-attribute instance-attribute

type: Literal["voice_stream_event_lifecycle"] = (
    "voice_stream_event_lifecycle"
)

事件类型。

VoiceStreamEventError dataclass

来自 VoicePipeline 的流式事件

源代码位于 src/agents/voice/events.py
@dataclass
class VoiceStreamEventError:
    """Streaming event from the VoicePipeline"""

    error: Exception
    """The error that occurred."""

    type: Literal["voice_stream_event_error"] = "voice_stream_event_error"
    """The type of event."""

error instance-attribute

error: Exception

发生的错误。

type class-attribute instance-attribute

type: Literal["voice_stream_event_error"] = (
    "voice_stream_event_error"
)

事件类型。