[Frontend] Add server-side VAD for turn-based omni models (#6618)
Signed-off-by: LHXuuu <xulianhao.xlh@antgroup.com>
This commit is contained in:
1 parent
031612f250
commit
c9c25b33c3
36 files changed
+4446
-940
No files matched your search
@@ -39,6 +39,11 @@ class NativeRuntimeBridgeMixin:
|
||||
}
|
||||
|
||||
async def _open_runtime_session(self, session: DuplexSession, send_json) -> dict[str, object] | bool:
|
||||
# Turn-based sessions use the chat-fallback path and do not own a
|
||||
# model-native duplex runtime. Do not send control messages merely
|
||||
# because the shared engine client exposes the duplex RPC methods.
|
||||
if not self._uses_serving_runtime_adapter(session.config):
|
||||
return True
|
||||
contract_error = self._native_runtime_contract_error(session)
|
||||
if contract_error is not None:
|
||||
await send_json(
|
||||
@@ -535,6 +540,8 @@ class NativeRuntimeBridgeMixin:
|
||||
session_config: dict[str, object] | None = None,
|
||||
runtime_config: dict[str, object] | None = None,
|
||||
) -> bool:
|
||||
if not self._uses_serving_runtime_adapter(session.config):
|
||||
return True
|
||||
signal_turn = getattr(self._chat_service.engine_client, "signal_duplex_turn_async", None)
|
||||
if not callable(signal_turn):
|
||||
return True
|
||||
@@ -582,6 +589,8 @@ class NativeRuntimeBridgeMixin:
|
||||
return True
|
||||
|
||||
async def _close_runtime_session(self, session: DuplexSession, *, reason: str, send_json=None) -> bool:
|
||||
if not self._uses_serving_runtime_adapter(session.config):
|
||||
return True
|
||||
close_session = getattr(self._chat_service.engine_client, "close_duplex_session_async", None)
|
||||
if not callable(close_session):
|
||||
return True
|
||||
@@ -1301,11 +1310,19 @@ class NativeRuntimeBridgeMixin:
|
||||
|
||||
def _cleanup_duplex_session_state(self, session: DuplexSession) -> None:
|
||||
session_id = session.session_id
|
||||
self._serving_runtime_adapter.remove_session_state(session_id)
|
||||
self._serving_runtime_adapter.data_plane.close_session(
|
||||
session_id,
|
||||
active_request_id=session.active_request_id,
|
||||
)
|
||||
pipeline = self._server_vad_pipelines.pop(session_id, None)
|
||||
if pipeline is not None:
|
||||
pipeline.reset()
|
||||
self._realtime_vad_metrics.session_finished()
|
||||
adapter = self._serving_runtime_adapter
|
||||
if adapter is None:
|
||||
self._serving_session_states.pop(session_id, None)
|
||||
else:
|
||||
adapter.remove_session_state(session_id)
|
||||
adapter.data_plane.close_session(
|
||||
session_id,
|
||||
active_request_id=session.active_request_id,
|
||||
)
|
||||
|
||||
def _encode_native_data_plane_audio(
|
||||
self,
|
||||
|
||||
Reference in new issue
Block a user