Fix finalization pattern: Use request/confirm in Pipecat mode, finalized flag in STT mode

- Add request_finalize() before sending ForceEndpoint in Pipecat mode
- Keep confirm_finalize() when receiving formatted finals in Pipecat mode
- Remove confirm_finalize() from STT mode (use finalized=True instead)

This follows Pipecat's two-step finalization pattern where request_finalize()
is called when sending a finalize request to the STT service, and
confirm_finalize() is called when receiving confirmation back.
This commit is contained in:
zack
2026-02-27 14:55:22 -05:00
parent cd07937c5d
commit aa7e9a17d5

View File

@@ -438,6 +438,7 @@ class AssemblyAISTTService(WebsocketSTTService):
and self._websocket
and self._websocket.state is State.OPEN
):
await self.request_finalize()
await self._websocket.send(json.dumps({"type": "ForceEndpoint"}))
await self.start_processing_metrics()
@@ -761,8 +762,7 @@ class AssemblyAISTTService(WebsocketSTTService):
self._user_speaking = True
if is_final_turn:
if message.turn_is_formatted:
self.confirm_finalize()
# STT mode: AssemblyAI controls finalization, just mark as finalized
await self.push_frame(
TranscriptionFrame(
transcript_text,