[Full Duplex] Feat: Support Full-Duplex realtime runtime & add MiniCPM-o 4.5 demo (#3907)
Signed-off-by: Sy03 <1370724210@qq.com> Signed-off-by: lishunyang12 <lishunyang03@gmail.com> Signed-off-by: Yueqian Lin <linyueqian@outlook.com> Co-authored-by: lishunyang12 <lishunyang03@gmail.com> Co-authored-by: Yueqian Lin <linyueqian@outlook.com> Co-authored-by: StormMelody <22371184@zju.edu.cn> Co-authored-by: Gao Han <hgaoaf@connect.ust.hk> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
142 files changed
+48389
-1013
No files matched your search
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class CommitAction(str, Enum):
|
||||
"""How one native audio commit participates in response scheduling."""
|
||||
|
||||
START_AUTO_RESPONSE = "start_auto_response"
|
||||
DEFER_ACTIVE_RESPONSE = "defer_active_response"
|
||||
COMMIT_ONLY = "commit_only"
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class CommitSnapshot:
|
||||
auto_responds: bool
|
||||
speech_since_commit: bool
|
||||
active_response_id: str | None
|
||||
overlap_speech_ms: int
|
||||
native_response_in_progress: bool
|
||||
playback_active: bool
|
||||
|
||||
|
||||
def decide_commit_action(snapshot: CommitSnapshot) -> CommitAction:
|
||||
"""Choose response scheduling from an immutable session snapshot."""
|
||||
if snapshot.auto_responds:
|
||||
if snapshot.speech_since_commit:
|
||||
return CommitAction.START_AUTO_RESPONSE
|
||||
return CommitAction.COMMIT_ONLY
|
||||
if snapshot.native_response_in_progress and snapshot.overlap_speech_ms > 0:
|
||||
return CommitAction.DEFER_ACTIVE_RESPONSE
|
||||
if snapshot.playback_active and snapshot.overlap_speech_ms > 0:
|
||||
return CommitAction.DEFER_ACTIVE_RESPONSE
|
||||
return CommitAction.COMMIT_ONLY
|
||||
|
||||
|
||||
__all__ = ["CommitAction", "CommitSnapshot", "decide_commit_action"]
|
||||
Reference in new issue
Block a user