ScoreFollow API
给音乐教育平台、陪练应用接入用:上传 PDF 乐谱得到 MusicXML 和每个小节在页面上的位置;上传弦乐(小提琴、中提琴、大提琴)录音,得到每个小节、每个音的音准和节奏结果。自动读出的小节线需要人看一眼时,把我们的托管校对页发给你的用户,保存后 webhook 通知你。还可以生成一个托管的走谱回放页,嵌进你的应用。
For music-education platforms: PDF to MusicXML with measure positions on the page, and measure-by-measure pitch and rhythm scoring of violin, viola and cello takes. When the automatic bar lines need a human check, send your user our hosted editor and get a webhook when they save. Or embed a hosted playback page with a cursor that follows the take.
开始 · Getting started
- 登录后在 我的 页底部打开「开发者 API」,创建密钥(
sfk_…,只显示一次)。Sign in, open Developer API at the bottom of Me, create a key. - 请求头带
Authorization: Bearer sfk_…。密钥只放在服务器上。Keep keys server-side. - 免费额度:每个密钥每天 100 次分析、20 次识谱,同时最多 2 个任务(UTC 0 点重置)。Free: 100 analyses, 20 readings per key per UTC day, 2 jobs at once.
KEY=sfk_...
API=https://mega-metro.online/api/v1
curl -s -H "Authorization: Bearer $KEY" -H "Content-Type: application/pdf" \
--data-binary @etude.pdf "$API/scores?filename=etude.pdf"
curl -s -H "Authorization: Bearer $KEY" "$API/scores/SCORE_ID"
curl -s -H "Authorization: Bearer $KEY" --data-binary @take.m4a \
"$API/analyses?scoreId=SCORE_ID&instrument=violin"
curl -s -H "Authorization: Bearer $KEY" "$API/analyses/ANALYSIS_ID"接口 · Endpoints
| POST | /scores?filename=… | Upload a PDF (application/pdf, ≤15 MB) or MusicXML · 上传 PDF 或 MusicXML |
| GET | /scores/{id} | Status, measure count, page layout, measure boxes, flags · 状态、小节框、可疑处 |
| GET | /scores/{id}/musicxml | Recognized MusicXML · 识别出的 MusicXML |
| POST | /scores/{id}/edit-session | Signed 7-day link to the hosted bar-line editor · 托管校对页链接 |
| PUT | /scores/{id}/layout | Save a corrected layout {revision, layout} · 提交修正后的布局 |
| DELETE | /scores/{id} | Delete score, files and analyses · 删除 |
| POST | /analyses?scoreId=…&instrument=violin|viola|cello | Upload a recording (≤300 s; wav/mp3/m4a/ogg/flac) · 上传录音 |
| GET | /analyses/{id} | Scores per take, per measure (with PDF boxes) and per note · 逐小节、逐音结果 |
| POST | /analyses/{id}/player?ttl=… | Signed link to a hosted playback page: recording + score + moving cursor · 托管走谱回放页链接 |
| GET | /usage | Today's usage and limits · 今日用量 |
坐标都是页面宽、高的比例(0–1)。一个谱行的小节从 left 到第一条小节线,再逐条到下一条。flags 标出可能读错的地方:count_mismatch、narrow_measure(可能把符干当成小节线)、wide_measure(可能漏了一条)。Coordinates are fractions of page width/height.
错误格式 · Errors: {"error": {"code": "...", "message": "..."}}. 429 daily_quota / concurrency_limit; 503 backend = busy, retry later. Refused jobs don't count.
走谱回放页 · Hosted player
POST /analyses/{id}/player 返回 {"url", "expires"}:一个可以直接打开或放进 iframe 的页面,播放这次录音,光标在 PDF 乐谱上跟着走,每个小节按结果上色,点哪个小节就从哪里播。链接默认 7 天有效,ttl(300–604800 秒)可以设得更短;拿到链接的人都能看。录音保留 30 天,删除乐谱时一起删除;过期后返回 409 no_audio。
Returns a page you can open or embed in an iframe: the take plays while a cursor follows it on the PDF, measures are coloured by result, and tapping a measure jumps there. Links last 7 days by default (shorten with ttl, 300–604800 s); anyone with the link can view. Recordings are kept 30 days, then 409 no_audio.
curl -s -X POST -H "Authorization: Bearer $KEY" "$API/analyses/ANALYSIS_ID/player?ttl=86400" <iframe src="https://mega-metro.online/scorefollow/play/?t=…" style="width:100%;height:80vh;border:0" allow="autoplay"></iframe>
Webhook
在密钥上设置 https 地址(必须是公网地址),会得到签名密钥 whsec_…。事件:score.ready、score.failed、score.updated、analysis.completed、analysis.failed。失败会在 10 秒、1 分、5 分、30 分、2 小时、6 小时后重试;可能重复或乱序,请按事件 id 去重。
# X-ScoreFollow-Signature: t=<unix>,v1=<hex HMAC-SHA256(secret, "<t>.<raw body>")>
import hmac, hashlib, time
def verify(secret: str, body: bytes, header: str) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
mac = hmac.new(secret.encode(), f"{parts['t']}.".encode() + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(mac, parts["v1"]) and abs(time.time() - int(parts["t"])) < 300数据 · Data
通过 API 提交的乐谱和录音不进入我们的改进资料库;用于回放的录音保留 30 天;删除乐谱即删除文件和结果。Scores and recordings sent through the API are not added to our corpus; recordings for the player are kept 30 days; deleting a score deletes its files and results. 隐私说明