Module livekit.plugins.spatialreal_ai.resumable_queue_io

Classes

class ResumableQueueAudioOutput (*,
sample_rate: int | None = None,
wait_playback_start: bool = False,
can_pause: bool = False)
Expand source code
class ResumableQueueAudioOutput(
    QueueAudioOutput,
    rtc.EventEmitter[Literal["clear_buffer", "pause", "resume"]],
):
    """Queue output that forwards the framework's pause/resume to the avatar.

    Pause is advertised only when the SpatialReal server can hold playback; otherwise
    the framework falls back to interrupting outright.
    """

    def __init__(
        self,
        *,
        sample_rate: int | None = None,
        wait_playback_start: bool = False,
        can_pause: bool = False,
    ) -> None:
        super().__init__(sample_rate=sample_rate, wait_playback_start=wait_playback_start)
        self._capabilities = AudioOutputCapabilities(pause=can_pause)
        self._paused = False

    def pause(self) -> None:
        if self._paused:
            return
        self._paused = True
        self.emit("pause")  # type: ignore[arg-type]

    def resume(self) -> None:
        if not self._paused:
            return
        self._paused = False
        self.emit("resume")  # type: ignore[arg-type]

    def clear_buffer(self) -> None:
        self._paused = False
        super().clear_buffer()

Queue output that forwards the framework's pause/resume to the avatar.

Pause is advertised only when the SpatialReal server can hold playback; otherwise the framework falls back to interrupting outright.

Args

sample_rate
The sample rate required by the audio sink, if None, any sample rate is accepted

Ancestors

  • livekit.agents.voice.avatar._queue_io.QueueAudioOutput
  • AudioOutput
  • livekit.agents.voice.avatar._types.AudioReceiver
  • abc.ABC
  • EventEmitter
  • typing.Generic

Methods

def clear_buffer(self) ‑> None
Expand source code
def clear_buffer(self) -> None:
    self._paused = False
    super().clear_buffer()

Clear the audio buffer

Inherited members