feat: 新增小米 MiMo 云端转写引擎(切片并发 + 断点续跑) - #99
Open
fatmmouse wants to merge 1 commit into
Open
Conversation
MiMo (mimo-v2.5-asr) is reached over an OpenAI-compatible chat
completions endpoint with input_audio, so it slots in next to the
existing providers and only needs the new `mimo` extra.
Long audio is the interesting part. A single request per file does not
scale to hour-long lectures, so the audio is split into 60s chunks:
- chunks run concurrently; `--workers` / `mimo.workers` sets how many
(default 4, which stays clear of the API's rate limit)
- each chunk retries with backoff, so one 429 in the middle of a
90-minute job no longer discards everything transcribed so far
- successful chunks are cached under .b2t/cache/mimo, keyed by chunk
audio content plus model and language, so re-running an interrupted
job only transcribes (and pays for) what is missing
Also fixes an unrelated crash found while testing local files: when a
transcription has no download step, metadata["download"] is None, and
`.get("download", {})` returns None rather than the default.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这个 PR 做了什么
新增小米 MiMo(
mimo-v2.5-asr)作为第四个转写引擎。它走的是 OpenAI 兼容的 chat completions +input_audio协议,所以实现上和现有 provider 结构一致,只多了一个mimoextra(依赖仅openai)。配置项和其他云端引擎一样走 bootstrap,README / CHANGELOG(中英)都已同步。
长音频的处理
单请求整段音频喂不动一个半小时的视频,所以按 60 秒切片,然后:
--workers/ 配置项mimo.workers控制并发数,默认 4--workers 8跑 94 片会挂 9 片;重试之后偶发限流可以自愈,不至于让整个长任务作废.b2t/cache/mimo/,key 是切片音频内容的哈希 + 模型 + 语言。重跑时重新切出来的分片字节一致,所以中断后原样重跑只会转缺失的部分,不会重复计费。换模型或语言会正常 miss实测:93 分钟的讲座,
--workers 6约 25 分钟出稿;中断重跑补 9 个切片只花了几分钟。顺带修了一个 bug
library.py里result.metadata.get("download", {}).get("title"):本地文件转写时download这个 key 是存在的、值为None,.get的默认值不会生效,于是None.get(...)抛错。改成(... or {})。这个和 MiMo 无关,是测试本地文件时撞到的,如果不希望混在这个 PR 里我可以拆出去。测试
新增
tests/test_mimo.py(5 个用例,用假 client 不打网络):缓存命中不重复请求、不同模型/语言不会错误复用缓存、未配置缓存目录时不缓存、重试成功后结果入缓存、重试耗尽正常抛错。全量测试 61 passed。另外用真实 API 端到端跑过 B站视频和本地音频。
一个想听听意见的点
--workers现在挂在通用的transcribe命令上,但目前只有 MiMo 会切片、用得到它,其他 provider 传了不生效。是保持现状(后续有别的 provider 支持并发时直接复用),还是您更希望只留配置项、不暴露成 CLI 参数?我按您的意见改。