Repository navigation
feat(server): let Bazarr fetch subtitles from akou, by answering its whisper /asr and /detect-language - #396
Merged
Merged
Conversation
…les from akou with no key
Bazarr's whisperai provider sends POST {endpoint}/asr with raw 16 kHz mono
s16le PCM in one `audio_file` part and no key, and POST
{endpoint}/detect-language with the whole track. akou now answers both under
/v1 while `server.bazarr` (AKOU_BAZARR, file or env only) is on, and 404 while
it is off. Raw PCM gets a 44-byte WAV header so the decoder reads it without
ffmpeg; the answer is an SRT, WebVTT or text from the job's result, with
42-character cues at the audio's own times. Detection transcribes the first
30 s under `best` and answers whisper-asr-webservice's JSON shape.
Refs akou-5an.39
…rr at akou Refs akou-5an.39
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 seconds. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
# Conflicts: # docs/ux/SERVER.md # src/main/api/routes/server.ts
…itle never runs past a line
Under Qwen no word has a time, so renderResult fell back to whole segments
and an SRT cue for Bazarr or GET /v1/jobs/{id}/result could run far past
CUE_CHARS. segmentCues cuts such a segment at word boundaries and shares its
time across the cues by character count, so the cues partition the segment.
…true, and what Home Assistant waits for The 30 s cap applies to Bazarr's raw PCM only. Home Assistant waits for a first preset download and reads the language list at setup, so a new preset needs an entry reload.
GeiserX
added a commit
that referenced
this pull request
Oct 12, 2026
… window behaves (#400) The version bump for 1.1.0. The release itself is the `v1.1.0` tag on main once this is merged and `ci-ok` is green there. ## What 1.1.0 ships The CHANGELOG section in this PR is the release note. In short: the server speaks Wyoming for Home Assistant's Assist (#395) and answers Bazarr's whisper endpoints (#396), both off by default; the desktop window stops scrolling past the app and the note and fix boxes grow with their text (#397); the ask box pre-starts the harness (#393); the recognizer loads from the call's start (#394); on four x64 cores a live line commits 0.4 s sooner (#391); the Docker Hub page is filled from the README (#389, #390); the watchdog test and the nightly stop flaking (#392, #399). ## The evidence a stable release needs (CI-28) - **The 8-hour soak**, at real time with a busy process on every core, through the Rust helper in file mode, on main at b87ba3b (every change in this release but the UI-only #397): 9 of 9 checks ok, no audio hole, heap growth 0.16 MB, event loop late by at most 186 ms. The JSON is `docs/gates/soak-1.1.0.json`. - **The terms table** has a row dated 2026-10-12. Both vendors' pages were read again today. Anthropic's pages are unchanged word for word. OpenAI's pages refuse plain fetches and the web archive was offline, so they were read in a browser: same dates, same clauses. The Consumer Terms outside the EEA could not be re-read today, and the row says so. - `bun scripts/stamp-version.ts --check --tag v1.1.0` exits 0; with `v1.1.1` it exits 1, the control. ## Also in this PR - The server docs' image tags and the README's DMG name say 1.1.0. - `docs/DESIGN.md` step 6 states the x64 provisional rule that #391 introduced, which the judge of that PR asked for. Depends on #399 merging first, since the CHANGELOG names it; I will bring main into this branch once it lands.
GeiserX
added a commit
that referenced
this pull request
Oct 13, 2026
…preset (#405) Bazarr now sends whole films to the server (#396). A model that hears room noise or music and no speech can write a sentence anyway ("thank you for watching", the way Qwen3-ASR did before sherpa-onnx 1.13.8), or loop on one word. On a film that becomes a wrong subtitle. SV-R5 was partial: the job pass already trimmed noise with the VAD, but the recognizer loaded before the VAD ran, the result had no way to say "no speech", nothing caught a decoder loop, and only `fast` and `auto` were tested. The fix: - **VAD before any model.** Every job runs the VAD before anything loads. A file with no speech ends `done` with `text: ""`, `segments: []` and a new `note: "no_speech"`, and loads no recognizer and no engine. Leading and trailing noise is still trimmed, with segment times in the file's clock, and a piece the VAD heard no speech in is still never decoded. - **Loop guard.** A decoded piece that loops on a short phrase keeps the phrase once and the words after it, in its text and its words alike. The bar is eight repeats in a row for a one- or two-word phrase and five for three or four words, so film lines such as "No, no, no, no, no!" or "Go! Go! Go!" stay whole. Han and kana text is matched by character with punctuation passed over, so a loop of 谢谢观看。 is cut to one, and a whitespace-split Qwen word holding it is cut to the same characters. - **Logs.** Each undecoded piece and each cut is one `debug` line with times and counts, never the dropped text. Debug lines go to `app.log` only. - **Bazarr.** `/asr` on noise answers 200 with an empty subtitle. `/detect-language` with no speech in the first 30 s answers 200 `unknown` / `und`. Tests, all named `[T4.37]` (new TRAPS row "Invented sentence on silence"): - `tests/silence-guards.test.ts` covers room noise through each preset's pass shape (recognizer, one engine, fusion list) with engines that invent on every unit: empty text, `no_speech`, nothing loaded or asked. A positive control shows that -30 dBFS pink noise does reach the engines and come back invented when the VAD is only an energy gate. Where the Silero model is on disk, the real VAD runs on -30 dBFS white and pink noise, and on the first sentence of the generated `two-voices.wav` fixture in noise. The speech keeps its text and its times in the file's clock. The loop-guard cases are in the same file. - Through the API: `fast` and `auto` in `jobs.e2e`, `best` (the fake Qwen gets no request), `fusion` (no engine runs), and both Bazarr routes. - The `server-macos` CI job already pulls the real `fast` models. It now runs `silence-guards.test.ts` and fails if a test skips there. The check jobs skip those two tests, so `maxSkip` goes up by 2. - Mutation checks run locally: with the loop guard disabled, 4 loop tests fail. With a bar of 5 for short phrases, the film-line tests fail. Without the word alignment, the Han words test fails. Without the energy gate, the digital-silence test fails, because its VAD hears speech everywhere. With the recognizer loaded before the VAD again, the recognizer-shape noise test and the real-VAD noise test fail. With the trim disabled, the speech-in-noise test fails. - Two halving fixtures said "world hello" 35 times, which is a loop by the guard's own rule. They now cycle five words. Not verified: how a real Bazarr instance handles an empty SRT body.
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.
Bazarr cannot get subtitles from akou today. Its Whisper provider sends
POST {endpoint}/asrwith raw 16 kHz mono s16le PCM in oneaudio_filepart, no key andUser-Agent: Subliminal/2.1, andPOST {endpoint}/detect-languagewith the whole track. akou has neither route,GET /v1/serverhardcodescapabilities.bazarr: false, and SERVER.md marks SV-C3 missing.The fix
POST /v1/asrandPOST /v1/detect-language(newsrc/main/api/routes/bazarr.ts). Bazarr's endpoint ishttp://host:8476/v1. Both routes are open, and they answer only whileserver.bazarris on (AKOU_BAZARR, file or env only,apiWritable: false). Off, both answer 404not_foundwith "server.bazarr is off". A key sent asAuthorization: Beareris honoured and the job runs under it. With no key the job runs as the stand-in identitybazarr.encode=false: the spool gets a 44-byte WAV header and is copied once, hashed on the way, so the decoder reads it without ffmpeg.encode=truepasses the container to ffmpeg as sent./asrruns the server default (chooseModel(jobs, {}, …, true)), inlanguageorserver.default_language, as a quiet job with the OpenAI door's wait loop. A caller that hangs up cancels the job, and the job is deleted once the answer is sent.output=srt|vtt|txtcomes fromrenderResult, so cues hold at most 42 characters and keep the audio's own times.task=translateis 400bad_param./detect-languagetranscribes only the first 30 s (960 000 PCM bytes) of raw PCM underbest. Withencode=true, which Bazarr never sends, the whole file is decoded; the route doc and docs/server.md say so. It answers{detected_language, language_code, confidence: null}, orunknown/undwhen no language was heard. Withbestrefused, akou's own 409 JSON passes through.bazarr:warn line in the server log, with the status and code.capabilities.bazarrishas("POST", "/asr") && server.bazarr === true. The header comment ofroutes/server.tsgains the clause for dialects a setting turns on.COMPAT_TAGS = ["openai", "bazarr"]inopenapi.ts, so both routes carryx-akou-door: compatand stay out of the?scope=jobsview.server.bazarrafterserver.behind_proxy, a "Bazarr" group after "Other servers", and its label beforeserver.dictation_slots.serverJobGaps, and the regenerateddocs/configuration.md,docs/api/openapi.jsonanddocs/cli.md.has, line 13 says all three dialects are built, and README.md:29, docs/index.md:90 and docs/server.md:3 are flipped back from "planned". docs/server.md gets a Home Assistant and a Bazarr section (endpoint, Host rule, no key, timeout, translate,best, Test Connection, a curl check).The Wyoming lane (#395) merged first, and main is merged into this branch (a merge commit, no rebase), so the shared sentences that call Wyoming built are true.
The one experiment (design section 6)
A job with
language=jw(andhaw,no) through the fake llama rig, onbestand onfast: every job came backdonewith "hello world". Qwen does not knowjw, so it falls back to auto and namesen; Parakeet keeps the hint. No 500, so there is nojw→jvmapping.Tests
tests/bazarr.e2e.test.ts, 12 tests, all[SV-C3]:/asrrequest: a hand-built multipart body (a part with a filename and no Content-Type),User-Agent: Subliminal/2.1, no Authorization,encode=falseraw s16le of 3 s silence plus "hello world". It gets 200text/plainand an SRT whose first cue starts at or after00:00:02,500. The job ran asbazarr, and no upload is left.PATCH /v1/configrefuses the key.not_found, capabilities false./detect-languageon the fake llama with--fake-lang Spanishanswersspanish/es/null on a 40 s track, and the decoder saw exactly 480 000 samples.bestrefused (auto_download off, no Qwen): 409preset_unavailable, nolanguage_code, a warn line.queue_fullJSON, and the refused body is never kept.The contract tests changed with it:
tests/openapi.test.ts(new control: abazarr-tagged operation without the door is reported),tests/scopes.test.ts,tests/server-mode.e2e.test.ts(capabilities.bazarrfalse by default),tests/api.e2e.test.ts(file-only keys),tests/server-image.test.ts.CI: a new step in the
serverjob,Bazarr-shaped /asr against the image (SV-C3). It starts the image withAKOU_BAZARR=true, checkscapabilities.bazarr, decodes en.wav to s16le with the image's ffmpeg, sends Bazarr's request with curl, and checks the SRT.Red controls, each watched failing
Each mutation was applied to a scratch copy, the test file was run, and the mutation was reverted.
Expected substring or pattern: /^1\r?\n(\d\d:\d\d:\d\d,\d{3}) --> \d\d:\d\d:\d\d,\d{3}\r?\nhello world//Received: "hello world\n".expect(received).toBeGreaterThanOrEqual(expected)/Expected: >= 0/Received: -1on the first cue's start against00:00:02,500.capabilities.bazarrignoring the setting:Expected: false/Received: truein the off test./asr:Expected: "/asr?output=srt&encode=false 404"/Received: "/asr?output=srt&encode=false 200"./detect-languagenot capped at 30 s:Expected: 480000/Received: 642240.Expected to end with: " key key_ecdc16a4"/Received: "job.created job_… key bazarr".COMPAT_TAGSwithoutbazarr:+ "POST /v1/asr: x-akou-door: compat on tag bazarr, not one of openai"in the committed-file check.is not SRTon a JSON refusal, and the same bytes as a text part (no filename) get 413 or 422, so the main test really sends a file part.On real models (a Mac mini M4,
akou servefrom this branch, Parakeet and Qwen on disk)The exact curl of the CI step, on en.wav decoded to s16le:
With
bestas the default, Qwen gives no word times; before the cue fix below this gave one whole-segment cue, now the segment is cut into cues of at most 42 characters.task=translategives 400bad_paramand the log lineakou warn: bazarr: POST /v1/asr 400 bad_param: task=translate is not supported: akou transcribes in the language spoken./detect-languagegives{"detected_language":"english","language_code":"en","confidence":null}. Every job logskey bazarr.Merged main after Wyoming (#395)
git merge origin/main(c8f18df). Two textual conflicts, resolved with the design's final text:src/main/api/routes/server.tscapabilities: Wyoming'swyoming: (c.app.wyomingPort?.() ?? null) !== nulland this branch'sbazarr:line, each with its comment. The header clause for dialects a setting turns on stays.docs/ux/SERVER.md: Wyoming's SV-C2 row and this branch's SV-C3 row.Schema keys, settings labels and groups, the capability assertions in
tests/server-mode.e2e.test.ts, bothserverJobGapslists, the file-only keys intests/api.e2e.test.ts,ci.ymland the other SERVER.md rows merged cleanly at their separate anchors.docs/configuration.mdanddocs/cli.mdregenerate byte-identical after the merge;docs/api/openapi.jsonchanged only by the detect-language doc line below.Cue fix: a segment with no word times is cut into 42-character cues
The 42-character rule (SV-J5) applied only when every word had times. Under Qwen no word does, so
renderResultfell back to whole segments and a Bazarr SRT cue could run far past 42 characters. The fix is in the sharedrenderResult, so the OpenAI door andGET /v1/jobs/{id}/resultget it too:segmentCuescuts a long segment at word boundaries into cues of at mostCUE_CHARS, and shares the segment's time across them by character count, so the cues partition the segment. No existing test pinned the old fallback; thewordCuesunit test still expects null for untimed words, which is unchanged.Test
[SV-J5] a segment with no timed words (Qwen) is cut into cues of at most 42 characters that partition its timeintests/openai.e2e.test.ts: one 120-character segment from 10 s to 22 s with untimed words, rendered as SRT. Every cue is at most 42 characters, the first starts at00:00:10,000, each starts where the last ended, the last ends at00:00:22,000, and the joined text is the segment's. Red on the previous head e1ec120 with the renderer unchanged:Doc lines
server.auto_downloadon (the default), the first utterance after turning on a preset that is not downloaded waits for the download, and Home Assistant may hit its 300 s pipeline timeout once. After a new preset is installed the Wyoming entry needs a reload, because it reads the language list at setup./detect-languageroute doc: withencode=truethe whole file is decoded.Deviations from the design
capabilities.bazarrfromserver.json. But the SV-T6 step runsdocker rm -f akou, andcompose-e2e.shtears its stack down on exit, so nothing listens on 8476 after it. The step starts its own container with-e AKOU_BEHIND_PROXY=true -e AKOU_BAZARR=trueand reads/v1/serverfrom it. It no longer depends on the Wyoming lane addingAKOU_BAZARRto the maindocker runline, and this branch does not touch that line.tr -s ' \n' ' '). The design's line-by-line grep fails on a split cue; the join passes it and still fails on a refusal body.index.tsis not this lane's.JobServicegains a publiclog(level, msg)that forwards to its existingo.log(src/main/server/jobs.ts, 4 lines).tests/scopes.test.ts. The SV-T5 walk runs an app-mode server, where a server-only route is an unknown path (UNKNOWN_ROUTE: any key). It expected open rows to pass with no key, so the first server-only open routes failed it. The walk now treats a server-only row asjobsthere, and the positive control counts only the open rows the app serves. The design said no access test needed an edit; it missed this one.tests/api.e2e.test.tslists every file-only key;server.bazarrjoins it beside the Wyoming lane's two keys.Bazarr itself was not run; CI and the box above send the request its source builds.
Refs akou-5an.39