Skip to content

fix: remote transcription posts to /transcribe, not /align (stem-splitter#17) - #959

Merged
topkoa merged 4 commits into
mainfrom
fix/remote-transcribe-endpoint
Jul 14, 2026
Merged

topkoa merged 4 commits into
mainfrom
fix/remote-transcribe-endpoint

Conversation

@topkoa

@topkoa topkoa commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Client half of feedBack-plugin-stem-splitter#17. Pairs with feedBack-demucs-server#14, which adds the endpoint — merge that one first.

Remote transcription has never worked

transcribe_vocals_remote() POSTs the vocal stem to /align. That endpoint is forced alignment — "here are the lyrics, tell me when each word is sung" — and its text field is required. We have no lyrics; transcribing them is the entire point.

So the server rejected every request with a 422 from FastAPI's validation layer, before its handler ever ran. Not a regression — this path has never worked for anybody.

Three fixes

  1. POST to /transcribe, which takes only the audio.

  2. language moves from the query string to the form body, where the server actually reads it (Form("")). As a query param it was silently ignored — so an explicit hint did nothing, Whisper's auto-detection quietly decided instead, and the wrong wav2vec2 aligner got loaded. It "worked", it was just wrong: the failure mode that hides for months.

  3. Error bodies are no longer cut at 300 chars. The body is the diagnosis — a 422's JSON names the field it rejected, a 500's traceback answers on its last line. Both got decapitated, which is part of why this stayed invisible: the message explaining the bug was inside the part that got cut.

Why nothing caught it

Every test of this module tested the mapper (_whisperx_to_sloppak), fed a hand-written dict. The mapper was always fine. The request was never exercised, and the request was the bug.

tests/test_lyrics_transcribe_remote.py now pins the request itself: the endpoint, the form field, the multipart upload, the bearer token, an instrumental returning no lyrics rather than an error, and a 404 carrying "the server is too old" through instead of swallowing it.

Verified the two key tests fail against the old /align + params call.

Compatibility

A server predating /transcribe answers 404, and the error now says so plainly rather than being truncated into noise.

Lyrics suite green (25). The two test_builtin_diagnostic_seed symlink failures are pre-existing on main — a Windows symlink-privilege artefact, unrelated to this change.

Summary by CodeRabbit

  • New Features

    • Updated remote vocal transcription to use the current transcription endpoint.
    • Language hints are now sent as a form field (only when provided).
    • Added support for sending API-key authentication with remote requests.
    • Instrumental/no-singing responses now return empty lyric results.
  • Bug Fixes

    • Improved error handling by including informative server error details and applying safe truncation for large error bodies, including clearer 404 messaging.
  • Tests

    • Added regression tests covering endpoint targeting, request/form encoding, multipart upload, authentication header behavior, and error-body/truncation edge cases.

…tter#17)

transcribe_vocals_remote() POSTed the vocal stem to /align. That endpoint is FORCED ALIGNMENT —
"here are the lyrics, tell me when each word is sung" — and its `text` field is required. We have
no lyrics; transcribing them is the entire point. So the server rejected every request with a 422
from FastAPI's validation layer, before its handler ever ran, and remote transcription has never
worked for anyone.

It now posts to /transcribe (added in feedBack-demucs-server#14), which takes only the audio.

`language` moves from the query string to the FORM BODY, where the server actually reads it
(Form("")). As a query param it was silently ignored, so an explicit hint did nothing and
Whisper's auto-detection quietly decided instead — loading the wrong wav2vec2 aligner. It
"worked", it was just wrong, which is the failure mode that hides for months.

Error bodies are no longer cut at 300 chars. The body IS the diagnosis: a 422's JSON names the
field it rejected, a 500's traceback answers on its LAST line. Both got decapitated — which is
part of why this stayed invisible for so long. The message explaining the bug was inside the part
that got cut.

Nothing caught any of this because every test of this module tested the MAPPER, fed a hand-written
dict. The mapper was always fine. The request was never exercised, and the request was the bug.
tests/test_lyrics_transcribe_remote.py now pins it: the endpoint, the form field, the multipart
upload, the bearer token, an instrumental returning no lyrics rather than an error, and a 404
saying the server is too old. Verified they FAIL against /align + params.

Signed-off-by: topkoa <topkoa@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@topkoa, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 09f056ef-f77a-4513-8df1-7a05d2d09b4a

📥 Commits

Reviewing files that changed from the base of the PR and between 0e7e74c and 6503301.

📒 Files selected for processing (2)
  • lib/lyrics_transcribe.py
  • tests/test_lyrics_transcribe_remote.py
📝 Walkthrough

Walkthrough

Remote vocal transcription now posts to /transcribe, sends optional language hints as form data, bounds server error text, and adds tests for request construction, successful empty results, authorization, and error propagation.

Changes

Remote transcription flow

Layer / File(s) Summary
Transcription request and error handling
lib/lyrics_transcribe.py
The remote client uses /transcribe, sends language in form data, documents endpoint compatibility, and raises errors using capped server response text.
Remote contract regression tests
tests/test_lyrics_transcribe_remote.py
Tests cover endpoint selection, multipart uploads, authorization, language handling, instrumental responses, server errors, error-body limits, and 404 details.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant transcribe_vocals_remote
  participant TranscriptionServer
  Client->>transcribe_vocals_remote: Submit vocals and optional language
  transcribe_vocals_remote->>TranscriptionServer: POST multipart request to /transcribe
  TranscriptionServer-->>transcribe_vocals_remote: Return segments or error body
  transcribe_vocals_remote-->>Client: Return mapped lyrics or RuntimeError
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: remote transcription now posts to /transcribe instead of /align.
Description check ✅ Passed The description explains the change, motivation, compatibility impact, and test coverage, with only template-specific headings missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remote-transcribe-endpoint

Comment @coderabbitai help to get the list of available commands.

@topkoa
topkoa requested a review from Copilot July 14, 2026 05:32
@topkoa

topkoa commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/test_lyrics_transcribe_remote.py (1)

109-119: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the new >4,000-character truncation path.

This fixture exceeds 300 characters but remains below _MAX_ERR_BODY, so it verifies removal of the old cutoff without testing the new bound or truncation marker. Add a separate oversized-body case.

Proposed test
+def test_a_very_large_server_error_is_bounded(vocals):
+    body = "x" * 5000
+    with pytest.raises(RuntimeError) as exc:
+        _post_call(vocals, _Resp(status=500, text=body))
+    assert "… [truncated, 5000 chars total]" in str(exc.value)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_lyrics_transcribe_remote.py` around lines 109 - 119, Add a
separate test near test_a_server_error_surfaces_the_whole_body that supplies a
response body longer than _MAX_ERR_BODY, then assert the raised RuntimeError
contains the retained truncated content and the truncation marker while
excluding content beyond the limit. Keep the existing test focused on preserving
complete bodies below the new bound.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/lyrics_transcribe.py`:
- Around line 484-511: Update the public docstring of the transcription function
containing the `/transcribe` request to document the `/transcribe` endpoint
instead of the obsolete `/align` endpoint, keeping the documentation consistent
with the implementation.

---

Nitpick comments:
In `@tests/test_lyrics_transcribe_remote.py`:
- Around line 109-119: Add a separate test near
test_a_server_error_surfaces_the_whole_body that supplies a response body longer
than _MAX_ERR_BODY, then assert the raised RuntimeError contains the retained
truncated content and the truncation marker while excluding content beyond the
limit. Keep the existing test focused on preserving complete bodies below the
new bound.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fc31b7e3-4158-4252-95dc-1bc5c0ffca95

📥 Commits

Reviewing files that changed from the base of the PR and between dd1927e and f5b9edb.

📒 Files selected for processing (2)
  • lib/lyrics_transcribe.py
  • tests/test_lyrics_transcribe_remote.py

Comment thread lib/lyrics_transcribe.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the remote WhisperX transcription client so it calls the correct server endpoint and sends parameters in the shape the server expects, and adds focused tests to prevent regressions in the HTTP request contract.

Changes:

  • Switch remote transcription from POST /align (forced-alignment) to POST /transcribe (audio-only transcription).
  • Move the language hint from query params to multipart form data, and keep API key auth via Bearer token.
  • Improve error reporting by surfacing larger server error bodies and add a new test suite that asserts the exact request shape and key failure modes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/lyrics_transcribe.py Updates the remote transcription request (endpoint + form field) and improves server error body handling.
tests/test_lyrics_transcribe_remote.py Adds request-level tests that pin endpoint selection, multipart upload shape, language handling, auth header, and error surfacing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/lyrics_transcribe.py Resolved
… endpoint

- _err_body() appended the truncation marker AFTER slicing to _MAX_ERR_BODY, so the result could
  exceed the cap it exists to enforce (4014 chars for a 4000 bound). A cap that is only a
  suggestion surprises exactly the callers who trust it — a log line, a job record persisted to
  disk and re-read on every load. The marker now fits inside the bound.

  It also stripped after measuring, so a short JSON body followed by kilobytes of trailing
  whitespace got truncated: real content cut to make room for blanks. Strip first, then measure.

- The public docstring still advertised /align — the exact contract this PR exists to change, in
  the one place a reader would look for it. It now says what the function does and why, and that
  an older server answers 404.

Found by Copilot and CodeRabbit on #959.

Signed-off-by: topkoa <topkoa@gmail.com>
@topkoa
topkoa requested a review from Copilot July 14, 2026 05:40
@topkoa

topkoa commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread lib/lyrics_transcribe.py Resolved
_err_body() kept only the HEAD of an over-long body. On a traceback the last line is the
diagnosis, and the docstring said exactly that while the code threw it away: a 4000-char window
holding "Traceback (most recent call last)" and none of the exception is a window onto nothing.
Same mistake as the 300-char cap it replaced, one level up — cutting off precisely the part the
function exists to preserve.

Head AND tail now, both inside the bound: two thirds head (what was being attempted), one third
tail (what actually went wrong), with the marker between them. Verified the test FAILS against
head-only truncation.

Found by Copilot on #959.

Signed-off-by: topkoa <topkoa@gmail.com>
@topkoa
topkoa requested a review from Copilot July 14, 2026 05:48
@topkoa

topkoa commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread lib/lyrics_transcribe.py Outdated
Comment on lines +525 to +529
with open(vocals_path, "rb") as f:
resp = requests.post(
f"{server_url}/align",
f"{server_url}/transcribe",
files={"file": (vocals_path.name, f, "audio/ogg")},
params=params,
data=form or None,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both good, and the first has teeth: the caller (_maybe_transcribe_lyrics) catches RuntimeError specifically, so one song's failed lyrics don't take down the batch around it. A DNS failure or a timeout coming out as requests.RequestException walks straight past that handler — turning "this song's lyrics failed" into "the whole batch died", which is a much worse day for someone converting an album.

Every exit is a RuntimeError now: transport errors, an unreadable stem, and non-200s. Tests cover connection failure, timeout, and a missing stem file.

The 404 explains itself too — a bare "404" sends someone hunting for a typo in their server URL, when the real answer is that their server predates /transcribe and only we are in a position to know that.

…r; 404 says why

The docstring promised one failure mode — RuntimeError — and the caller (_maybe_transcribe_lyrics)
catches exactly that so one song's failed lyrics don't take down the batch around it. But a DNS
failure, a timeout, a reset connection or an unreadable stem escaped as requests.RequestException
or OSError, walked straight past that handler, and turned "this song's lyrics failed" into "the
whole batch died".

A 404 now explains itself. Bare "404" sends someone hunting for a typo in their server URL; the
real answer is that their server predates /transcribe, and we are the only ones in a position to
know that.

Found by Copilot on #959.

Signed-off-by: topkoa <topkoa@gmail.com>
@topkoa
topkoa requested a review from Copilot July 14, 2026 05:55
@topkoa

topkoa commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@topkoa
topkoa merged commit 0d35228 into main Jul 14, 2026
7 checks passed
@topkoa
topkoa deleted the fix/remote-transcribe-endpoint branch July 14, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants