Skip to content

Commit 0de3d9f

Browse files
fix(openai): skip realtime truncate when no audio was played
1 parent de1a4ee commit 0de3d9f

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

  • livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime

livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/realtime_model.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,14 +1615,15 @@ def truncate(
16151615
audio_transcript: NotGivenOr[str] = NOT_GIVEN,
16161616
) -> None:
16171617
if "audio" in modalities:
1618-
self.send_event(
1619-
ConversationItemTruncateEvent(
1620-
type="conversation.item.truncate",
1621-
content_index=0,
1622-
item_id=message_id,
1623-
audio_end_ms=audio_end_ms,
1618+
if audio_end_ms > 0:
1619+
self.send_event(
1620+
ConversationItemTruncateEvent(
1621+
type="conversation.item.truncate",
1622+
content_index=0,
1623+
item_id=message_id,
1624+
audio_end_ms=audio_end_ms,
1625+
)
16241626
)
1625-
)
16261627
elif utils.is_given(audio_transcript):
16271628
# sync the forwarded text to the remote chat ctx
16281629
chat_ctx = self.chat_ctx.copy(

0 commit comments

Comments
 (0)