fix(voice): stop thinking continuation on silence
This commit is contained in:
@@ -563,12 +563,20 @@ class AudioSocketMediaRuntime:
|
||||
def _buffer_thinking_continuation(self, actor: MediaActor, pcm_frame: bytes, *, is_speech: bool, now: float) -> None:
|
||||
if not is_speech and not actor.thinking_continuation_pcm:
|
||||
return
|
||||
if (
|
||||
not is_speech
|
||||
and actor.thinking_continuation_deadline_monotonic > 0
|
||||
and now > actor.thinking_continuation_deadline_monotonic
|
||||
):
|
||||
return
|
||||
remaining = self._thinking_continuation_max_bytes - len(actor.thinking_continuation_pcm)
|
||||
if remaining <= 0:
|
||||
actor.thinking_continuation_deadline_monotonic = now + self._thinking_continuation_grace_seconds
|
||||
if is_speech:
|
||||
actor.thinking_continuation_deadline_monotonic = now + self._thinking_continuation_grace_seconds
|
||||
return
|
||||
actor.thinking_continuation_pcm.extend(pcm_frame[:remaining])
|
||||
actor.thinking_continuation_deadline_monotonic = now + self._thinking_continuation_grace_seconds
|
||||
if is_speech:
|
||||
actor.thinking_continuation_deadline_monotonic = now + self._thinking_continuation_grace_seconds
|
||||
|
||||
async def _extend_with_thinking_continuation(self, actor: MediaActor, pcm_bytes: bytes) -> bytes:
|
||||
deadline = time.monotonic() + self._thinking_continuation_grace_seconds
|
||||
|
||||
Reference in New Issue
Block a user