Skip to content

feat: dubbing support in the SDK and CLI (+ free-trial awareness) - #16

Merged
spencer-zqian merged 10 commits into
mainfrom
feat/dubbing
Jul 24, 2026
Merged

feat: dubbing support in the SDK and CLI (+ free-trial awareness)#16
spencer-zqian merged 10 commits into
mainfrom
feat/dubbing

Conversation

@spencer-zqian

@spencer-zqian spencer-zqian commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Exposes the newly-shipped POST /v1/dubbing endpoint. Note this branch also carries a second, unrelated feature — see part 2.

1. Dubbing

  • client.dubbing.submit() / .generate() on both Sonilo and AsyncSonilo.
  • New DubbingResult dataclass: results arrive as outputs, a map of language code to dubbed .mp4 URL. This envelope is unlike every other endpoint's, so it does not reuse SoundResult. save(language, path) fetches one; save_all(directory) fetches every one, plus asave/asave_all.
  • video_url is checked for https:// locally — the dubbing pipeline fetches the source itself and rejects plain http with a 422.
  • Language codes are not validated client-side: the backend owns that list, and a hardcoded copy would make this SDK reject codes added server-side later.
  • New sonilo dubbing CLI command. Because a dubbing task returns one video per language, --output is a filename template: --output clip.mp4 writes clip.es.mp4 and clip.fr.mp4 — the same transform --stem already uses.
  • --timeout defaults to 7200 seconds, matching the backend's own ceiling — it polls its pipeline for up to 7200s, so any shorter client-side wait abandons jobs that are still succeeding and leaves the caller charged for videos they never receive.
  • Corrects the free-trial documentation in both READMEs and in context7.json: dubbing has zero free runs (it bills duration × languages), so the previous "free runs on every endpoint" / "1 each for the video endpoints" wording told users the most expensive endpoint in the product was free to try.

Bumps sonilo to 0.6.0 and sonilo-cli to 0.2.0.

2. Free-trial awareness

One commit from concurrent work that landed on this branch: surfacing the free trial before it runs out, and naming it when it does.

Test plan

python -m pytest tests -q (192 passed) and python -m pytest sonilo-cli/tests -q (39 passed), run separately — running both directories in one invocation hits a pre-existing test-package name collision that predates this branch.

Dubbing coverage: form encoding, the https guard, the exactly-one-input guard, unknown-code pass-through, the parser, the save helpers, sync + async generate() polling, the --output template transform, --languages parsing, and one-file-per-language writing.

@sapient-app

sapient-app Bot commented Jul 24, 2026

Copy link
Copy Markdown

Sapient docs evals

Waiting for the staging docs URL before running evals.

Sapient will start the selected PR evals automatically when GitHub reports a successful docs deployment for this PR. This usually happens within 15 minutes.

Commit: e02a87d
Status: waiting for staging docs URL

- README: pass an explicit timeout=3600 in the dubbing sample and explain
  that the SDK's 600s default wait is far shorter than the dubbing
  pipeline can take, and that a client-side timeout does not cancel or
  refund the task.
- sonilo-cli README: document the dubbing --timeout default and that a
  timed-out wait is resumable with `sonilo tasks wait <task-id>`.
- sonilo-cli tests: cover the omitted --languages path (no `languages`
  field sent) and assert the stderr text of the non-https exit-1 case.
- tests/test_dubbing.py: move a stray mid-file import to the header.
…does

Add TrialExhaustedError (a PaymentRequiredError subclass) for the 402 whose
body carries code: "trial_exhausted", so callers can tell "you have never
paid us" apart from a funded wallet that ran dry without matching on message
text. Type account.services() as AccountServices/TrialQuota TypedDicts — the
trial quota was reachable at runtime but invisible to type checkers and
undocumented — and document the three 402 codes.

sonilo account now prints a one-line trial summary on stderr (stdout stays
pure JSON), and the CLI's error handler no longer drops the API's error code.

Bumps sonilo to 0.7.0 and sonilo-cli to 0.3.0.
The dubbing backend polls its pipeline for up to 7200s. Giving up at 3600s
still abandons jobs that are running fine, leaving a caller charged for
videos they never receive. Match the backend exactly so the client gives up
only once the backend has.
@spencer-zqian spencer-zqian changed the title feat: dubbing support in the SDK and CLI feat: dubbing support in the SDK and CLI (+ free-trial awareness) Jul 24, 2026
sonilo-video-kit pinned sonilo<0.6, so every editable install of the
workspace broke the moment sonilo went to 0.6.0 — CI could not even reach
the test step. Widening to <1.0 matches what the JS video-kit already does
(>=0.5.1 <1.0.0) and stops this recurring on the next minor bump. Bumped to
0.1.3 so the published package carries the working range too.
@spencer-zqian
spencer-zqian merged commit 1ca3588 into main Jul 24, 2026
2 checks passed
@spencer-zqian
spencer-zqian deleted the feat/dubbing branch July 24, 2026 22:13
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.

1 participant