Spaces:
Running
Running
Reference transcript, About links, logo sizing
Browse files
app.py
CHANGED
|
@@ -40,6 +40,7 @@ import base64
|
|
| 40 |
import html
|
| 41 |
import json
|
| 42 |
import os
|
|
|
|
| 43 |
from pathlib import Path
|
| 44 |
|
| 45 |
import gradio as gr
|
|
@@ -82,8 +83,10 @@ HIDDEN_BOARDS: frozenset = frozenset()
|
|
| 82 |
# A flat record with "verdict" (better|worse) is one half of a curated TTS
|
| 83 |
# contrast pair: it renders as a colored chip + player row under its group
|
| 84 |
# (the eval's display name), whose shared prompt "transcript" prints once at
|
| 85 |
-
# the lead-in.
|
| 86 |
-
#
|
|
|
|
|
|
|
| 87 |
# A record with "turns" is a conversation (STS samples) rendered as a card:
|
| 88 |
# header = model (or "label" for stimulus cards) + optional "score"
|
| 89 |
# ({value, max, label}) badge + "verdict"/"verdict_label" chip + "caption";
|
|
@@ -349,6 +352,16 @@ def load_about() -> dict:
|
|
| 349 |
return {}
|
| 350 |
|
| 351 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
def render_about(about: dict) -> str:
|
| 353 |
"""The About tab: intro paragraphs, one clickable card per leaderboard
|
| 354 |
panel (title + description, click = jump to that tab), outro. Panels whose
|
|
@@ -357,7 +370,7 @@ def render_about(about: dict) -> str:
|
|
| 357 |
tabs = {label for label, _key, _fname in MODALITIES}
|
| 358 |
parts = ["<div class='ttslb abt'>"]
|
| 359 |
for p in about.get("intro", []):
|
| 360 |
-
parts.append(
|
| 361 |
cards = []
|
| 362 |
for panel in about.get("panels", []):
|
| 363 |
if panel.get("tab") not in tabs:
|
|
@@ -370,7 +383,7 @@ def render_about(about: dict) -> str:
|
|
| 370 |
f"<span class='abt-go'>β</span></div>{body}</div>")
|
| 371 |
parts.append("<div class='abt-cards'>" + "".join(cards) + "</div>")
|
| 372 |
for p in about.get("outro", []):
|
| 373 |
-
parts.append(
|
| 374 |
parts.append("</div>")
|
| 375 |
return "".join(parts)
|
| 376 |
|
|
@@ -571,6 +584,8 @@ TABLE_CSS = """
|
|
| 571 |
font-size:12.5px; line-height:1.5; color:var(--lb-ink-2); }
|
| 572 |
.ttslb .smp-gtx.long { max-height:76px; overflow-y:auto; margin-left:14px; padding:8px 10px;
|
| 573 |
border:1px solid var(--lb-row-line); border-radius:8px; }
|
|
|
|
|
|
|
| 574 |
/* a Scenario blurb starting the next group gets breathing room after the
|
| 575 |
previous group's cards */
|
| 576 |
.ttslb .smp-convo + .smp-gnote { margin-top:20px; }
|
|
@@ -630,6 +645,10 @@ TABLE_CSS = """
|
|
| 630 |
(title + description; the whole card jumps to that tab via APP_JS). */
|
| 631 |
.ttslb.abt { max-width:920px; }
|
| 632 |
.ttslb .abt-p { margin:8px 2px; font-size:13px; line-height:1.55; color:var(--lb-ink-2); text-align:left; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 633 |
.ttslb .abt-cards { display:grid; grid-template-columns:repeat(auto-fill, minmax(360px, 1fr));
|
| 634 |
gap:12px; margin:14px 0 12px; }
|
| 635 |
.ttslb .abt-card { border:1px solid var(--lb-border); border-radius:10px; padding:13px 16px;
|
|
@@ -1130,6 +1149,14 @@ def render_samples_section(samples: list, factor_labels: dict,
|
|
| 1130 |
rows_html.append(f"<div class='smp-group'>{html.escape(group)}{count}</div>")
|
| 1131 |
shared_tx = False
|
| 1132 |
if pair:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1133 |
txs = {(r.get("transcript") or "").strip() for r in grp_rows}
|
| 1134 |
tx = txs.pop() if len(txs) == 1 else ""
|
| 1135 |
if tx:
|
|
@@ -1185,13 +1212,15 @@ def build_demo() -> gr.Blocks:
|
|
| 1185 |
# NB: the CSS/JS goes to launch(head=...) β gradio 6 moved `head` off Blocks.
|
| 1186 |
with gr.Blocks(title=title) as demo:
|
| 1187 |
if _LOGO_URI:
|
|
|
|
|
|
|
| 1188 |
if _LOGO_DARK_URI:
|
| 1189 |
logo = (f"<img src='{_LOGO_URI}' alt='Hume AI'"
|
| 1190 |
-
" style='height:
|
| 1191 |
f"<img src='{_LOGO_DARK_URI}' alt='Hume AI'"
|
| 1192 |
-
" style='height:
|
| 1193 |
else:
|
| 1194 |
-
logo = f"<img src='{_LOGO_URI}' alt='Hume AI' style='height:
|
| 1195 |
gr.HTML(
|
| 1196 |
"<div style='display:flex;align-items:center;gap:14px'>"
|
| 1197 |
+ logo
|
|
|
|
| 40 |
import html
|
| 41 |
import json
|
| 42 |
import os
|
| 43 |
+
import re
|
| 44 |
from pathlib import Path
|
| 45 |
|
| 46 |
import gradio as gr
|
|
|
|
| 83 |
# A flat record with "verdict" (better|worse) is one half of a curated TTS
|
| 84 |
# contrast pair: it renders as a colored chip + player row under its group
|
| 85 |
# (the eval's display name), whose shared prompt "transcript" prints once at
|
| 86 |
+
# the lead-in. A pair's shared "reference_transcript" (the enrollment passage
|
| 87 |
+
# audible at the head of voice-identity clips) prints italicized above that β
|
| 88 |
+
# without it the clip seems to open with the wrong text. "model"/"score"/
|
| 89 |
+
# "instructions"/"tag"/"eval" ride along as provenance, never displayed.
|
| 90 |
# A record with "turns" is a conversation (STS samples) rendered as a card:
|
| 91 |
# header = model (or "label" for stimulus cards) + optional "score"
|
| 92 |
# ({value, max, label}) badge + "verdict"/"verdict_label" chip + "caption";
|
|
|
|
| 352 |
return {}
|
| 353 |
|
| 354 |
|
| 355 |
+
def _about_p(p: str) -> str:
|
| 356 |
+
"""An intro/outro paragraph: plain text, except markdown-style
|
| 357 |
+
[label](https://...) spans, which become links opening in a new tab
|
| 358 |
+
(e.g. the outro's technical-report PDF)."""
|
| 359 |
+
return "<p class='abt-p'>" + re.sub(
|
| 360 |
+
r"\[([^\]]+)\]\((https?://[^)\s]+)\)",
|
| 361 |
+
r"<a href='\2' target='_blank' rel='noopener'>\1</a>",
|
| 362 |
+
html.escape(p)) + "</p>"
|
| 363 |
+
|
| 364 |
+
|
| 365 |
def render_about(about: dict) -> str:
|
| 366 |
"""The About tab: intro paragraphs, one clickable card per leaderboard
|
| 367 |
panel (title + description, click = jump to that tab), outro. Panels whose
|
|
|
|
| 370 |
tabs = {label for label, _key, _fname in MODALITIES}
|
| 371 |
parts = ["<div class='ttslb abt'>"]
|
| 372 |
for p in about.get("intro", []):
|
| 373 |
+
parts.append(_about_p(p))
|
| 374 |
cards = []
|
| 375 |
for panel in about.get("panels", []):
|
| 376 |
if panel.get("tab") not in tabs:
|
|
|
|
| 383 |
f"<span class='abt-go'>β</span></div>{body}</div>")
|
| 384 |
parts.append("<div class='abt-cards'>" + "".join(cards) + "</div>")
|
| 385 |
for p in about.get("outro", []):
|
| 386 |
+
parts.append(_about_p(p))
|
| 387 |
parts.append("</div>")
|
| 388 |
return "".join(parts)
|
| 389 |
|
|
|
|
| 584 |
font-size:12.5px; line-height:1.5; color:var(--lb-ink-2); }
|
| 585 |
.ttslb .smp-gtx.long { max-height:76px; overflow-y:auto; margin-left:14px; padding:8px 10px;
|
| 586 |
border:1px solid var(--lb-row-line); border-radius:8px; }
|
| 587 |
+
/* the voice-identity pairs' enrollment passage, heard before the prompt text */
|
| 588 |
+
.ttslb .smp-gtx.ref { font-style:italic; margin-bottom:0; }
|
| 589 |
/* a Scenario blurb starting the next group gets breathing room after the
|
| 590 |
previous group's cards */
|
| 591 |
.ttslb .smp-convo + .smp-gnote { margin-top:20px; }
|
|
|
|
| 645 |
(title + description; the whole card jumps to that tab via APP_JS). */
|
| 646 |
.ttslb.abt { max-width:920px; }
|
| 647 |
.ttslb .abt-p { margin:8px 2px; font-size:13px; line-height:1.55; color:var(--lb-ink-2); text-align:left; }
|
| 648 |
+
/* gradio 6 skins every anchor like a button (2px 8px padding + press
|
| 649 |
+
transform) β flatten that back to a plain inline text link */
|
| 650 |
+
.ttslb .abt-p a { color:var(--lb-accent); padding:0 !important; }
|
| 651 |
+
.ttslb .abt-p a:active { transform:none !important; }
|
| 652 |
.ttslb .abt-cards { display:grid; grid-template-columns:repeat(auto-fill, minmax(360px, 1fr));
|
| 653 |
gap:12px; margin:14px 0 12px; }
|
| 654 |
.ttslb .abt-card { border:1px solid var(--lb-border); border-radius:10px; padding:13px 16px;
|
|
|
|
| 1149 |
rows_html.append(f"<div class='smp-group'>{html.escape(group)}{count}</div>")
|
| 1150 |
shared_tx = False
|
| 1151 |
if pair:
|
| 1152 |
+
# the enrollment passage heard at the head of each clip
|
| 1153 |
+
# (voice-identity evals) β shown so the opening audio
|
| 1154 |
+
# doesn't read as a mismatch with the prompt text
|
| 1155 |
+
refs = {(r.get("reference_transcript") or "").strip() for r in grp_rows}
|
| 1156 |
+
ref = refs.pop() if len(refs) == 1 else ""
|
| 1157 |
+
if ref:
|
| 1158 |
+
rows_html.append(f"<div class='smp-gtx ref'>Reference: "
|
| 1159 |
+
f"β{html.escape(ref)}β</div>")
|
| 1160 |
txs = {(r.get("transcript") or "").strip() for r in grp_rows}
|
| 1161 |
tx = txs.pop() if len(txs) == 1 else ""
|
| 1162 |
if tx:
|
|
|
|
| 1212 |
# NB: the CSS/JS goes to launch(head=...) β gradio 6 moved `head` off Blocks.
|
| 1213 |
with gr.Blocks(title=title) as demo:
|
| 1214 |
if _LOGO_URI:
|
| 1215 |
+
# 26px: the current wordmark asset is cropped to its ink (the original
|
| 1216 |
+
# had padding filling ~61% of a 48px box), sized down a touch further
|
| 1217 |
if _LOGO_DARK_URI:
|
| 1218 |
logo = (f"<img src='{_LOGO_URI}' alt='Hume AI'"
|
| 1219 |
+
" style='height:26px;display:var(--lb-logo-light,inline)'/>"
|
| 1220 |
f"<img src='{_LOGO_DARK_URI}' alt='Hume AI'"
|
| 1221 |
+
" style='height:26px;display:var(--lb-logo-dark,none)'/>")
|
| 1222 |
else:
|
| 1223 |
+
logo = f"<img src='{_LOGO_URI}' alt='Hume AI' style='height:26px'/>"
|
| 1224 |
gr.HTML(
|
| 1225 |
"<div style='display:flex;align-items:center;gap:14px'>"
|
| 1226 |
+ logo
|