Skip to content

feat(avatar): add sync-3 hosted lipsync via the sync. API - #994

Open
nachoiacovino wants to merge 1 commit into
OpenMontageInc:mainfrom
nachoiacovino:feat/sync-lipsync
Open

nachoiacovino wants to merge 1 commit into
OpenMontageInc:mainfrom
nachoiacovino:feat/sync-lipsync

Conversation

@nachoiacovino

Copy link
Copy Markdown

Summary

Adds sync-3 as a hosted lip-sync option through the sync. API: a new sync_lipsync tool (provider sync, env SYNC_API_KEY) that sits next to the local Wav2Lip lip_sync tool under the avatar capability. sync-3 is the default model; lipsync-2-pro and lipsync-2 are the cheaper per-second options.

sync-3 comes from the team behind Wav2Lip, which OpenMontage's lip_sync already runs. It adds what Wav2Lip struggles with: close-ups, profile and over-the-shoulder angles, hands or mics over the mouth, long takes, 4K output, and a still image as input. It needs no local GPU. localization-dub gets the most out of it.

I added a separate tool rather than a backend inside lip_sync. lip_sync is pinned as the local Wav2Lip tool (provider == "wav2lip", runtime local_gpu, asserted in test_kling_official_avatar.py), and hosted providers here get their own tool (kling_lip_sync, heygen_avatar). Both pipelines that use lip_sync now list sync_lipsync as an optional tool next to it, so it shows up as an option wherever lip sync does.

Billing is bring-your-own-key: each user creates a key at https://sync.so/settings/api-keys and is billed per output second by sync.

Related issue

None. Opened after the maintainer said yes to the proposal by email.

Changes

  • tools/avatar/sync_lipsync.py: new SyncLipSync(BaseTool), capability="avatar", auto-discovered by the registry.
    • Inputs: one of video_path / video_url / image_path / image_url (images need sync-3) plus audio_path or audio_url. model is one of sync-3 (default), lipsync-2-pro or lipsync-2. sync_mode is one of bounce (default), loop, cut_off, silence or remap. Also accepts active_speaker_detection and passthrough options.
    • Local files are uploaded through sync.'s presigned asset flow (POST /v2/assets/upload, PUT, POST /v2/assets). The API key is never sent to the upload URL, and nothing goes to a third-party host.
    • Submit-then-poll on POST /v2/generate and GET /v2/generate/{id}. Every submit carries an Idempotency-Key that is saved to job_path before the request. A timeout or 5xx on submit returns resume_job, and resuming replays the same key and body, so it can never create a second paid generation. A poll timeout returns resume_job with the generation id, and resuming only polls.
    • Options that sync-3 manages itself (temperature, occlusion_detection_enabled, reasoning_enabled) are rejected locally before any paid call. reasoning_enabled: true on sync-3 is an API 400.
    • NO_OP (nothing lipsynced, e.g. no face found) is reported as a failure, never as a finished lipsync. FAILED / REJECTED surface error_code. Plan and credit errors set needs_user_action. 429 concurrency_limit_reached is retryable through resume_job.
    • Cost: estimate_cost raises PriceQuoteRequired because pricing depends on the plan. dry_run: true returns a free quote from POST /v2/generations/estimate without uploading or generating, using ffprobe for a local audio_path or duration_seconds for a URL. A resume preflight returns the saved quote.
  • pipeline_defs/localization-dub.yaml, pipeline_defs/avatar-spokesperson.yaml: sync_lipsync added to optional_tools and tools_available next to lip_sync. Nothing is required, and no default routing changes.
  • .agents/skills/sync-lipsync/SKILL.md: Layer 3 skill covering model choice, inputs, speaker selection, sync modes, quoting, the dubbing workflow, failure codes and resume.
  • Docs: docs/PROVIDERS.md (env summary, quick-start row, provider section, provider table, avatar coverage), docs/ARCHITECTURE.md (avatar inventory, env table), .env.example (SYNC_API_KEY, optional SYNC_API_BASE_URL), skills/creative/lip-sync-usage.md, both asset-director skills, skills/INDEX.md.
  • tests/contracts/test_sync_lipsync.py: 35 tests with all HTTP faked. They cover metadata, registry discovery, status with and without the key, pipeline wiring, the local Wav2Lip tool being unchanged, request building and validation, upload, submit, poll and download, key saved before submit, resume with and without a generation id, poll timeout, FAILED/REJECTED/NO_OP, 429 and 402 handling, dry-run quotes, and the base URL override.

The existing lip_sync (Wav2Lip) tool is not modified.

Testing

  • pytest tests/contracts/test_sync_lipsync.py: 35 passed.
  • make lint passes.
  • Full pytest tests/: 2941 passed, 20 skipped, 9 failed. The same 9 tests fail on unmodified main on my machine, because local ffmpeg lacks libvorbis, drawtext and libass (audio_enhance libvorbis, bmts_lite, caption isolation, showcase_card). None touch this change; on main the totals were 2905 passed and the same 9 failed.
  • Registry check: with SYNC_API_KEY unset, sync_lipsync is discovered as unavailable with setup instructions and appears in provider_menu. With the key set it reports available.
  • Request shapes, option rules and status values were checked against sync.'s API definition and docs (https://sync.so/docs/models/sync-3, https://sync.so/docs/api-reference), verified 2026-11-30.
  • I have not run a live generation through SyncLipSync().execute(...) in this PR. Happy to do one and post the generation id, or to send you a budget-capped key so you can try it end to end.

Checklist

  • The change is focused on a single logical concern.
  • I ran the relevant tests locally (make test-contracts / make test) where applicable.
  • I updated docs/README if behavior or usage changed.
  • No unrelated files (build artifacts, local config) are included in the diff.

Disclosure: I work at sync. (sync.so).

🤖 Generated with Claude Code

Adds `sync_lipsync` (provider `sync`, env SYNC_API_KEY), a hosted lip-sync
option next to the local Wav2Lip `lip_sync` tool. It defaults to sync-3 and
also offers lipsync-2-pro and lipsync-2 as cheaper per-second options.

- Video or still-image input (image is sync-3 only) plus speech audio, local
  paths or public HTTPS URLs. Local files upload through sync.'s presigned
  asset flow; the API key is never sent to the upload URL.
- Submit-then-poll on POST /v2/generate and GET /v2/generate/{id}. Every
  submit carries an Idempotency-Key saved with the job before the request, so
  a timeout or 5xx is resumed with resume_job and cannot start a second paid
  generation.
- sync_mode, active_speaker_detection and native options pass through;
  options sync-3 manages itself (temperature, occlusion_detection_enabled,
  reasoning_enabled) are rejected locally before any paid call.
- NO_OP, FAILED and REJECTED are reported as failures with the error code;
  plan and credit errors set needs_user_action; 429 concurrency is retryable.
- estimate_cost raises PriceQuoteRequired (pricing varies by plan);
  dry_run returns a free quote from POST /v2/generations/estimate.
- Offered next to lip_sync in the localization-dub and avatar-spokesperson
  asset stages as an optional tool; the local Wav2Lip tool is unchanged.
- Layer 3 skill sync-lipsync, contract tests with faked HTTP, PROVIDERS.md,
  ARCHITECTURE.md, .env.example and lip-sync skill docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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