Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 4,800 Bytes
d9bc3e9 377037a d9bc3e9 377037a d9bc3e9 377037a d9bc3e9 377037a d9bc3e9 377037a d9bc3e9 377037a d9bc3e9 377037a d9bc3e9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | #!/usr/bin/env python3
"""
Submit the streaming ASR models (task ``streaming``), plus their offline siblings, to the FFASR
Space for moderation.
Maintainer tool. It calls the Space's public ``submit_model`` API, exactly like the Submit tab,
so every request waits for a moderator. The Space allows 5 submissions an hour per email and per
connection; the script waits out the window and carries on (about 2 hours for the full list).
python scripts/submit_streaming_models.py --dry-run # list what would be sent
python scripts/submit_streaming_models.py # submit, pacing for the rate limit
It refuses to run against a Space that does not offer the streaming task yet: older code would
quietly turn a streaming submission into an offline ASR one.
"""
from __future__ import annotations
import argparse
import html
import re
import sys
import time
SPACE = "treble-technologies/ffasr"
CONTACT = "contact@treble.tech"
# (model id, how it runs[, task]) — English-capable, natively streaming checkpoints on the Hub.
# The task defaults to "streaming"; "asr" entries go to the offline board.
MODELS: list[tuple[str, ...]] = [
("nvidia/nemotron-3.5-asr-streaming-0.6b", "Nemotron ASR streaming (Transformers), 560 ms"),
("nvidia/nemotron-speech-streaming-en-0.6b", "Nemotron ASR streaming (Transformers), 560 ms"),
("nvidia/parakeet_realtime_eou_120m-v1", "NeMo cache-aware streaming"),
("nvidia/stt_en_fastconformer_hybrid_large_streaming_multi", "NeMo cache-aware streaming, 560 ms"),
("mistralai/Voxtral-Mini-4B-Realtime-2602", "causal streaming model, 480 ms delay"),
("kyutai/stt-1b-en_fr", "Kyutai delayed streams (moshi), 0.5 s delay"),
("kyutai/stt-2.6b-en", "Kyutai delayed streams (moshi), 2.5 s delay"),
("moonshine-ai/moonshine-streaming-tiny", "causal streaming model"),
("moonshine-ai/moonshine-streaming-small", "causal streaming model"),
("moonshine-ai/moonshine-streaming-medium", "causal streaming model"),
("csukuangfj/sherpa-onnx-streaming-zipformer-en-2023-06-26", "sherpa-onnx online transducer, 320 ms chunk"),
("microsoft/VibeVoice-ASR-Streaming-7B", "VibeVoice streaming_generate, 2.93 s chunk + 0.53 s lookahead (L40S)"),
("microsoft/VibeVoice-ASR-Streaming-1.5B", "VibeVoice streaming_generate, 2.93 s chunk + 0.53 s lookahead"),
("microsoft/VibeVoice-ASR", "offline: vibevoice_asr recipe (L40S)", "asr"),
]
RATE_WAIT_S = 3660
def _text(status) -> str:
raw = status[0] if isinstance(status, (list, tuple)) else status
return re.sub(r"\s+", " ", html.unescape(re.sub(r"<[^>]+>", " ", str(raw or "")))).strip()
def _offers_streaming(client) -> bool:
for comp in (client.config or {}).get("components", []):
choices = (comp.get("props") or {}).get("choices") or []
if any((c[1] if isinstance(c, (list, tuple)) else c) == "streaming" for c in choices):
return True
return False
def main() -> int:
ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
ap.add_argument("--space", default=SPACE)
ap.add_argument("--email", default=CONTACT, help="contact email stored privately with each request")
ap.add_argument("--dry-run", action="store_true")
ap.add_argument("--only", nargs="*", help="submit only these model ids")
args = ap.parse_args()
todo = [(e[0], e[1], e[2] if len(e) > 2 else "streaming") for e in MODELS if not args.only or e[0] in args.only]
if args.dry_run:
for m, how, task in todo:
print(f"would submit {m} as {task} ({how})")
return 0
from gradio_client import Client
client = Client(args.space, verbose=False)
if not _offers_streaming(client):
print(f"{args.space} does not offer the streaming task yet. Deploy the streaming code first.", file=sys.stderr)
return 2
failed = 0
for model_id, how, task in todo:
board = "Streaming board" if task == "streaming" else "Offline board"
notes = f"[maintainer] {board}: {model_id}, {how}."
while True:
status = _text(
client.predict(
model_id, notes, args.email, "", "", "", "", False, task, "",
api_name="/submit_model",
)
)
if "Rate limit" in status:
print(f"rate limited; waiting {RATE_WAIT_S // 60} min before {model_id}", flush=True)
time.sleep(RATE_WAIT_S)
continue
break
ok = "We received request" in status or "is in the queue" in status
failed += 0 if ok or "already" in status else 1
print(f"{'OK ' if ok else 'SKIP'} {model_id}: {status[:300]}", flush=True)
return 1 if failed else 0
if __name__ == "__main__":
raise SystemExit(main())
|