.
This commit is contained in:
+23
-5
@@ -1140,7 +1140,7 @@ class CallSession:
|
||||
actually_spoken_chunks: list[str] = []
|
||||
assistant_audio_started = [False]
|
||||
transcript = ""
|
||||
filler_started = False
|
||||
filler_started = asyncio.Event()
|
||||
self._set_active_unanswered_turn(epoch=epoch, utterance_audio=utterance_audio)
|
||||
try:
|
||||
LOGGER.info(
|
||||
@@ -1276,6 +1276,7 @@ class CallSession:
|
||||
epoch=epoch,
|
||||
tool_name=None,
|
||||
started_monotonic=llm_started_monotonic,
|
||||
filler_started=filler_started,
|
||||
suppress=_is_terminal_farewell(transcript) or _is_farewell_transcript(transcript),
|
||||
),
|
||||
name=f"{self.session_id}-filler-delay-{epoch}",
|
||||
@@ -1289,16 +1290,16 @@ class CallSession:
|
||||
epoch,
|
||||
event.name,
|
||||
event.tool_call_id,
|
||||
filler_started,
|
||||
filler_started.is_set(),
|
||||
)
|
||||
if not filler_trigger_task.done():
|
||||
filler_trigger_task.cancel()
|
||||
if not filler_started:
|
||||
filler_started = True
|
||||
if not filler_started.is_set():
|
||||
self._start_filler_audio(
|
||||
epoch=epoch,
|
||||
tool_name=event.name,
|
||||
started_monotonic=llm_started_monotonic,
|
||||
filler_started=filler_started,
|
||||
)
|
||||
continue
|
||||
|
||||
@@ -1837,6 +1838,7 @@ class CallSession:
|
||||
epoch: int,
|
||||
tool_name: str | None,
|
||||
started_monotonic: float,
|
||||
filler_started: asyncio.Event,
|
||||
suppress: bool = False,
|
||||
) -> None:
|
||||
if suppress:
|
||||
@@ -1846,16 +1848,18 @@ class CallSession:
|
||||
epoch=epoch,
|
||||
tool_name=tool_name,
|
||||
started_monotonic=started_monotonic,
|
||||
filler_started=filler_started,
|
||||
)
|
||||
return
|
||||
await asyncio.sleep(FILLER_AUDIO_DELAY_MS / 1000.0)
|
||||
self._ensure_generation(epoch)
|
||||
if self._active_answer_audio_started:
|
||||
if self._active_answer_audio_started or filler_started.is_set():
|
||||
return
|
||||
self._start_filler_audio(
|
||||
epoch=epoch,
|
||||
tool_name=tool_name,
|
||||
started_monotonic=started_monotonic,
|
||||
filler_started=filler_started,
|
||||
)
|
||||
|
||||
def _start_filler_audio(
|
||||
@@ -1864,9 +1868,19 @@ class CallSession:
|
||||
epoch: int,
|
||||
tool_name: str | None,
|
||||
started_monotonic: float,
|
||||
filler_started: asyncio.Event,
|
||||
) -> None:
|
||||
if filler_started.is_set():
|
||||
LOGGER.info(
|
||||
"realtime session %s filler audio skipped: already started for current turn epoch=%s tool=%s",
|
||||
self.session_id,
|
||||
epoch,
|
||||
tool_name or "generic",
|
||||
)
|
||||
return
|
||||
if self._filler_task is not None and not self._filler_task.done():
|
||||
return
|
||||
filler_started.set()
|
||||
LOGGER.info(
|
||||
"realtime session %s filler audio scheduled: epoch=%s tool=%s",
|
||||
self.session_id,
|
||||
@@ -1878,6 +1892,7 @@ class CallSession:
|
||||
epoch=epoch,
|
||||
tool_name=tool_name,
|
||||
started_monotonic=started_monotonic,
|
||||
filler_started=filler_started,
|
||||
),
|
||||
name=f"{self.session_id}-filler-{epoch}",
|
||||
)
|
||||
@@ -1888,9 +1903,11 @@ class CallSession:
|
||||
epoch: int,
|
||||
tool_name: str | None,
|
||||
started_monotonic: float,
|
||||
filler_started: asyncio.Event,
|
||||
) -> None:
|
||||
if self._filler_audio is None:
|
||||
LOGGER.info("realtime session %s filler audio skipped: no library", self.session_id)
|
||||
filler_started.clear()
|
||||
return
|
||||
filler_pcm = self._filler_audio.pick(tool_name)
|
||||
if not filler_pcm:
|
||||
@@ -1899,6 +1916,7 @@ class CallSession:
|
||||
self.session_id,
|
||||
tool_name or "generic",
|
||||
)
|
||||
filler_started.clear()
|
||||
return
|
||||
first_audio_seen = False
|
||||
sent_chunks = 0
|
||||
|
||||
Reference in New Issue
Block a user