Skip to content

refactor: align Python and C++ encoding APIs - #34

Merged
zhenghaoz merged 1 commit into
mainfrom
refactor/python-encoding-api
Oct 27, 2026
Merged

zhenghaoz merged 1 commit into
mainfrom
refactor/python-encoding-api

Conversation

@zhangzhenghao

@zhangzhenghao zhangzhenghao commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Rename the public Python and C++ Model class to CLAP, and text / audio to encode_text / encode_audio.
  • Add Python encode_audio(path, crop_offset=0) for str and pathlib.Path, with native file decoding, mono downmixing and automatic model-rate resampling; retain PCM input support.
  • Remove Python's public decode_audio and resample_audio helpers; keep the native C++ helpers available.
  • Migrate native CLI/server callers, architecture test consumers and documentation. No legacy aliases are retained.

Verification

  • Built the CPU wheel through the default sdist-to-wheel python -m build python path, installed that wheel, and passed 51 Python integration tests.
  • Passed 26/26 CTest tests in each of static and shared Linux CPU builds.
  • Syntax-checked all migrated optional C++ architecture-test consumers.
  • Inspected wheel contents/licenses and ldd: no external ggml/ICU/OpenMP dependencies.
  • Independent review: no blocking security or correctness findings.
  • Unicode str/Path audio paths, stereo downmixing, non-native sample rate, crop offsets, missing/invalid files, closed handles and existing PCM/text behavior covered.
  • Local verification is Linux CPU only; GPU runtime behavior was not exercised.

Remote CI (5487508)

  • Python wheel build/install/tests passed on Linux x64, Linux ARM64, macOS and Windows x64.
  • Native build/test/install passed on Linux x64, Linux ARM64, macOS and Windows x64.
  • Native Windows ARM64 failed before compilation while generating audio fixtures: the installed yt-dlp FFmpeg crashes converting mono.wav to mono.flac with exit code 3221225477. The base main run 40102240289 at 519a84e fails at the identical command with the identical exit code. This is a pre-existing FFmpeg/tooling failure, not introduced by this API migration; workflow and fixture-generator files are unchanged.

@zhenghaoz
zhenghaoz merged commit 55a5f3b into main Oct 27, 2026
8 of 9 checks passed
@zhenghaoz
zhenghaoz deleted the refactor/python-encoding-api branch October 27, 2026 06:14
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