Fix UserSpeechMs growing indefinitely in Server VAD mode

TurnStartTime was only set in StartListening(), which is called once.
In Server VAD + interruption mode the mic stays open, so TurnStartTime
was never updated between turns. Now reset TurnStartTime when the agent
stops speaking (normal end + interruption), marking the start of the
next potential user turn.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
j.foucher 2026-03-05 18:27:14 +01:00
parent a8dd5a022f
commit 56b072c45e

View File

@ -279,6 +279,7 @@ void UPS_AI_ConvAgent_ElevenLabsComponent::TickComponent(float DeltaTime, ELevel
bHardTimeoutFired = bHardTimeout && !bAgentResponseReceived;
bAgentSpeaking = false;
bPreBuffering = false; // Cancel pending pre-buffer to prevent stale OnAudioPlaybackStarted.
TurnStartTime = FPlatformTime::Seconds(); // Mark start of next potential user turn.
bAgentResponseReceived = false;
SilentTickCount = 0;
bShouldBroadcastStopped = true;
@ -1516,6 +1517,7 @@ void UPS_AI_ConvAgent_ElevenLabsComponent::StopAgentAudio()
SilentTickCount = 0;
bWasSpeaking = true;
Now = FPlatformTime::Seconds();
TurnStartTime = Now; // Mark start of next potential user turn.
}
}