Spaces:
Running
Running
File size: 1,216 Bytes
d631808 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
from __future__ import annotations
from dataclasses import dataclass
from typing import Literal, Union
from typing_extensions import TypeAlias
from .imports import np, npt
@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."""
@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."""
@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."""
VoiceStreamEvent: TypeAlias = Union[
VoiceStreamEventAudio, VoiceStreamEventLifecycle, VoiceStreamEventError
]
"""An event from the `VoicePipeline`, streamed via `StreamedAudioResult.stream()`."""
|