Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions livekit-agents/livekit/agents/voice/avatar/_datastream_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import json
import math
import time
from collections.abc import AsyncIterator
from dataclasses import asdict
from typing import Any, Callable, Union
Expand Down Expand Up @@ -134,6 +135,10 @@ async def capture_frame(self, frame: rtc.AudioFrame) -> None:
},
)
self._pushed_duration = 0.0
# Not ideal since frame isn't actually playing yet
# potentially we need another RPC for this
self.on_playback_started(created_at=time.time())

await self._stream_writer.write(bytes(frame.data))
self._pushed_duration += frame.duration

Expand Down
6 changes: 5 additions & 1 deletion livekit-agents/livekit/agents/voice/avatar/_queue_io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import time
from collections.abc import AsyncIterator
from typing import Literal, Union

Expand All @@ -16,7 +17,7 @@
class QueueAudioOutput(
AudioOutput,
AudioReceiver,
rtc.EventEmitter[Literal["playback_finished", "clear_buffer"]],
rtc.EventEmitter[Literal["clear_buffer"]],
):
"""
AudioOutput implementation that sends audio frames through a queue.
Expand All @@ -37,6 +38,9 @@ async def capture_frame(self, frame: rtc.AudioFrame) -> None:
await super().capture_frame(frame)
if not self._capturing:
self._capturing = True
# Not ideal since frame isn't actually playing yet
# potentially we need another RPC/hook for this
self.on_playback_started(created_at=time.time())

await self._data_ch.send(frame)

Expand Down