[Cleanup][Full Duplex] Remove generic server VAD
Signed-off-by: Sy03 <1370724210@qq.com>
This commit is contained in:
1 parent
2a7407fe85
commit
d3780fdcb7
13 files changed
+17
-854
No files matched your search
@@ -494,26 +494,6 @@ class OmniDuplexSessionHandler(
|
||||
# playback only controls history ACKs, not model admission.
|
||||
if is_speech:
|
||||
session.accumulate_overlap_speech(duration_ms)
|
||||
vad_speech_started = self._vad_speech_started(event, payload)
|
||||
if (
|
||||
self._uses_native_input_append(session)
|
||||
and session.capabilities.supports_barge_in
|
||||
and is_speech
|
||||
and session.config.overlap_policy == DuplexOverlapPolicy.BARGE_IN_ON_SPEECH.value
|
||||
and vad_speech_started is not False
|
||||
):
|
||||
# The configured server overlap detector classified this chunk
|
||||
# as speech while the assistant is still generating/playing.
|
||||
# Fence the active response so the same interrupting chunk is
|
||||
# retained as the start of the next turn.
|
||||
return {
|
||||
"action": "barge_in",
|
||||
"reason": ("server_vad_speech_started" if vad_speech_started is True else "barge_in_on_speech"),
|
||||
"cancel_reason": "turn_detected" if vad_speech_started is True else "barge_in",
|
||||
"duration_ms": duration_ms,
|
||||
"overlap_speech_ms": session.overlap_speech_ms,
|
||||
"buffer_audio": True,
|
||||
}
|
||||
return {
|
||||
"action": "listen",
|
||||
"reason": "auto_response_continuous",
|
||||
@@ -573,22 +553,9 @@ class OmniDuplexSessionHandler(
|
||||
|
||||
session.accumulate_overlap_speech(duration_ms)
|
||||
if policy == DuplexOverlapPolicy.BARGE_IN_ON_SPEECH.value:
|
||||
vad_speech_started = self._vad_speech_started(event, payload)
|
||||
if vad_speech_started is False:
|
||||
return {
|
||||
"action": "listen",
|
||||
"reason": "server_vad_utterance_active",
|
||||
"duration_ms": duration_ms,
|
||||
"overlap_speech_ms": session.overlap_speech_ms,
|
||||
"buffer_audio": True,
|
||||
"defer_runtime_append": False,
|
||||
"force_listen": True,
|
||||
"preserve_realtime_input": True,
|
||||
}
|
||||
return {
|
||||
"action": "barge_in",
|
||||
"reason": ("server_vad_speech_started" if vad_speech_started is True else "policy_barge_in_on_speech"),
|
||||
"cancel_reason": "turn_detected" if vad_speech_started is True else "barge_in",
|
||||
"reason": "policy_barge_in_on_speech",
|
||||
"duration_ms": duration_ms,
|
||||
"overlap_speech_ms": session.overlap_speech_ms,
|
||||
"buffer_audio": True,
|
||||
@@ -632,18 +599,6 @@ class OmniDuplexSessionHandler(
|
||||
"defer_runtime_append": True,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _vad_speech_started(
|
||||
event: Mapping[str, object],
|
||||
payload: Mapping[str, object],
|
||||
) -> bool | None:
|
||||
"""Return an onset edge, or None for legacy non-server-VAD input."""
|
||||
for source in (event, payload):
|
||||
vad = source.get("vad")
|
||||
if isinstance(vad, Mapping) and isinstance(vad.get("speech_started"), bool):
|
||||
return bool(vad["speech_started"])
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _event_requests_barge_in(event: Mapping[str, object]) -> bool:
|
||||
if event.get("force_barge_in") is True:
|
||||
@@ -961,20 +916,6 @@ class OmniDuplexSessionHandler(
|
||||
max_sessions=self._duplex_session_config.max_sessions,
|
||||
)
|
||||
)
|
||||
if (
|
||||
config.overlap_policy == DuplexOverlapPolicy.BARGE_IN_ON_SPEECH.value
|
||||
and not session.capabilities.supports_barge_in
|
||||
):
|
||||
if realtime_protocol is not None:
|
||||
realtime_protocol.reject_realtime_turn_detection_update()
|
||||
await send_json(
|
||||
{
|
||||
"type": "error",
|
||||
"error": ("server_vad with interrupt_response=true requires a runtime that supports barge-in"),
|
||||
"code": "unsupported_turn_detection",
|
||||
}
|
||||
)
|
||||
return None
|
||||
session.replace_runtime_config(runtime_config)
|
||||
return _DuplexSessionHandshake(session=session)
|
||||
|
||||
|
||||
Reference in new issue
Block a user