ffasr / duplex_config.py
whojavumusic's picture
FFASR leaderboard: redesigned board, Avg WER chart, base-model grouping
5f0f535
Raw History Blame Contribute Delete
5.97 kB
"""
Full-duplex voice agent benchmark: conditions, metrics, CSV columns.
Import-light (no torch, pandas, or gradio) so a future Hub Job worker can share it.
Two acoustic conditions:
farfield agent on a device across the room (reverberant room, distant user)
glasses agent on smart glasses (mics near the wearer's mouth, open-ear speakers
right next to the mics, bystanders at conversation distance)
Metrics follow Full-Duplex-Bench (v1 / v1.5) where one exists. Every per-condition
value is stored in its own CSV column named ``<metric>_<condition>``
(e.g. ``pause_tor_glasses``). Rates are fractions (0-1), latencies are seconds.
"""
from __future__ import annotations
from dataclasses import dataclass
# Analysis-tab task value. Not a submit task: there is no duplex evaluation worker yet.
TASK_DUPLEX = "duplex"
ANALYSIS_TASK_CHOICE: tuple[str, str] = ("Full-duplex voice agents", TASK_DUPLEX)
def is_duplex(task: str | None) -> bool:
return (task or "").strip().lower() == TASK_DUPLEX
# ---------------------------------------------------------------------------
# Conditions
# ---------------------------------------------------------------------------
@dataclass(frozen=True)
class DuplexCondition:
key: str
label: str
description: str
CONDITIONS: tuple[DuplexCondition, ...] = (
DuplexCondition(
"farfield",
"Far field",
"The agent runs on a device across the room. The user talks from a distance in a "
"reverberant, noisy room.",
),
DuplexCondition(
"glasses",
"Smart glasses",
"The agent runs on head-worn glasses. The mics are close to the wearer's mouth, the "
"open-ear speakers sit next to the mics, and bystanders talk at conversation distance.",
),
)
CONDITIONS_BY_KEY: dict[str, DuplexCondition] = {c.key: c for c in CONDITIONS}
CONDITION_KEYS: tuple[str, ...] = tuple(c.key for c in CONDITIONS)
VIEW_ALL = "all"
VIEWS: tuple[tuple[str, str], ...] = (
("Both conditions", VIEW_ALL),
*((c.label, c.key) for c in CONDITIONS),
)
def conditions_for_view(view: str | None) -> tuple[str, ...]:
"""Condition keys averaged by a view (``all`` averages both)."""
v = (view or VIEW_ALL).strip().lower()
return (v,) if v in CONDITIONS_BY_KEY else CONDITION_KEYS
def view_label(view: str | None) -> str:
return next((label for label, key in VIEWS if key == (view or VIEW_ALL)), VIEWS[0][0])
# ---------------------------------------------------------------------------
# Metrics
# ---------------------------------------------------------------------------
@dataclass(frozen=True)
class DuplexMetric:
key: str
label: str
description: str
unit: str # "rate" (fraction 0-1), "s" (seconds), "jsd" (0-1), "score" (0-5)
lower_is_better: bool
METRICS: tuple[DuplexMetric, ...] = (
DuplexMetric(
"pause_tor",
"Pause takeover rate",
"Share of mid-sentence user pauses where the agent takes the floor.",
"rate",
True,
),
DuplexMetric(
"turn_tor",
"Turn-taking rate",
"Share of finished user turns where the agent answers.",
"rate",
False,
),
DuplexMetric(
"bargein_tor",
"Barge-in success rate",
"Share of user interruptions where the agent stops and answers the new request.",
"rate",
False,
),
DuplexMetric(
"false_bargein",
"False barge-in rate",
"Share of non-user speech (bystanders, TV, the user talking to someone else) where the "
"agent stops or answers.",
"rate",
True,
),
DuplexMetric(
"echo_stop",
"Echo self-interruption rate",
"Share of agent turns that the agent cuts off because it hears its own voice, with no "
"user speech.",
"rate",
True,
),
DuplexMetric(
"bc_jsd",
"Backchannel timing JSD",
"Jensen-Shannon divergence between the agent's and human backchannel timing (0 = human-like).",
"jsd",
True,
),
DuplexMetric(
"resp_latency_s",
"Response latency",
"Seconds from the end of the user's turn to the agent's first speech.",
"s",
True,
),
DuplexMetric(
"stop_latency_s",
"Stop latency",
"Seconds from the start of a user barge-in until the agent is silent.",
"s",
True,
),
DuplexMetric(
"bargein_score",
"Barge-in reply quality",
"LLM-judge score (0-5) of the agent's answer after a barge-in.",
"score",
False,
),
)
METRICS_BY_KEY: dict[str, DuplexMetric] = {m.key: m for m in METRICS}
METRIC_KEYS: tuple[str, ...] = tuple(m.key for m in METRICS)
@dataclass(frozen=True)
class Behavior:
"""One turn-taking behaviour as a failure rate (lower is better)."""
key: str
label: str
metric: str
invert: bool # failure = 1 - metric when the stored metric is a success rate
# The interaction error is the mean of these five failure rates.
BEHAVIORS: tuple[Behavior, ...] = (
Behavior("pause", "Pause takeover", "pause_tor", False),
Behavior("turn", "Missed turns", "turn_tor", True),
Behavior("bargein", "Missed barge-ins", "bargein_tor", True),
Behavior("false_bargein", "False barge-ins", "false_bargein", False),
Behavior("echo", "Echo self-stops", "echo_stop", False),
)
BEHAVIORS_BY_KEY: dict[str, Behavior] = {b.key: b for b in BEHAVIORS}
def metric_column(metric: str, cond_key: str) -> str:
return f"{metric}_{cond_key}"
METRIC_COLUMNS: tuple[str, ...] = tuple(
metric_column(m, c) for c in CONDITION_KEYS for m in METRIC_KEYS
)
ARCHITECTURES: tuple[str, ...] = ("End-to-end", "Cascaded")
CSV_FIELDS: list[str] = [
"model_id",
"eval_family",
"architecture",
*METRIC_COLUMNS,
"num_samples",
"submission_notes",
"submitted_at",
]