Skip to content

TFLite: Windows support + cross-platform CI (supersedes #66)#67

Merged
Cortexelus merged 4 commits into
mainfrom
tflite-windows
Jul 14, 2026
Merged

TFLite: Windows support + cross-platform CI (supersedes #66)#67
Cortexelus merged 4 commits into
mainfrom
tflite-windows

Conversation

@Cortexelus

Copy link
Copy Markdown
Collaborator

Windows support for the TFLite route, with a cross-platform CI matrix proving it. Supersedes #66@betweentwomidnights' commit is included verbatim (cherry-picked, authorship preserved); if squash-merging, please keep the Co-authored-by: betweentwomidnights <b2mkevin@gmail.com> trailer.

What's fixed

  • termios/tty import guard (Support TFLite CLI on Windows #66): the CLI now starts on Windows; the model picker uses the numeric fallback there (arrow keys stay on POSIX).
  • Weight materialization without symlink privileges: ensure_local now tries symlink → hardlink (os.link, privilege-free, zero-copy) → shutil.copy2. On stock Windows (no Developer Mode) the old symlink_to raised WinError 1314 on the very first lazy download — every fresh install hit it.
  • UTF-8 console: the banners (━ ▸ ▶ ✓ ⚠ ↓ + emoji) crashed with UnicodeEncodeError on cp1252 consoles. Guarded sys.stdout/stderr.reconfigure(encoding="utf-8", errors="replace") in the three entry scripts; os.system("") on NT enables VT colors in legacy cmd.
  • --play: platform dispatch — afplay (macOS, unchanged), winsound.PlaySound (Windows, stdlib), aplay or print-the-path (Linux).
  • sa3.bat + install.bat (CRLF-pinned via a scoped .gitattributes) and a README Windows section (ai-edge-litert ships win_amd64 wheels for Py 3.10–3.13; winget/choco ffmpeg; LongPathsEnabled note). Error hints are platform-aware instead of brew-only.
  • Audit sweep: two remaining POSIX-path assumptions fixed (sys.executable.split('/'), examples' invocation strings).

Everything is a guarded no-op on macOS/Linux.

CI: .github/workflows/tflite-cross-platform.yml

Matrix = exactly the ai-edge-litert wheel-support envelope: ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-latest (no macOS-Intel / Windows-ARM wheels exist). Per OS: install requirements, py_compile all scripts, LiteRT import, and a 9-test stdlib suite with zero model downloads — including a forced WinError-1314 symlink failure (asserting the hardlink/copy chain), --help + the emoji examples run in fresh interpreters with PYTHONUTF8/PYTHONIOENCODING stripped (genuinely exercising the encoding fix on the runners' native pipes), and per-platform --play dispatch selection. ~1.5 runner-minutes per push touching optimized/tflite/**.

All four jobs green on the first run: https://github.com/Stability-AI/stable-audio-3/actions/runs/29368663141 (windows-latest: 9/9 tests, hardlink fallback confirmed in the log).

Not verifiable without an interactive Windows box

Actual winsound playback (dispatch is tested, audio out isn't), the interactive feel of the numeric picker and .bat flows, and unprivileged real-HF downloads (the forced-failure test covers the chain deterministically). A quick smoke from any Windows user would close these.

betweentwomidnights and others added 4 commits July 14, 2026 17:03
… dispatch

- weights.py: ensure_local materializes files via symlink -> hardlink -> copy
  (Windows without Developer Mode can't create symlinks, WinError 1314);
  prints which fallback was used the first time one occurs
- sa3_tflite.py / install.py / examples.py: guarded stdout/stderr
  reconfigure(encoding=utf-8) so box-drawing/emoji banners survive legacy
  cp1252 consoles, plus os.system('') on nt to enable ANSI/VT in cmd.exe
- sa3_tflite.py: --play now dispatches per platform (afplay on macOS,
  stdlib winsound on Windows, aplay on Linux with a printed-path fallback);
  dispatcher split into _play_backend() for import-testing
- platform-aware ffmpeg/python install hints (brew / apt / winget);
  examples.py knows .venv\Scripts\python.exe and sa3.bat on Windows

All changes are no-ops on macOS/Linux.
- sa3.bat / install.bat: batch twins of ./sa3 and ./install.sh — plain
  python -m venv + pip (no uv), prefer .venv\Scripts\python.exe, forward
  all args; CRLF-pinned via a scoped .gitattributes
- README: Windows subsection under Install (install.bat / sa3.bat usage,
  ai-edge-litert win_amd64 wheels for Python 3.10-3.13, optional ffmpeg via
  winget/choco, LongPathsEnabled registry note for deep HF-cache paths);
  --play wording updated to the per-platform players
New workflow runs on every OS ai-edge-litert ships wheels for (manylinux
x86_64 + aarch64, win_amd64, macosx_12_0_arm64 — hence no macos-13 and no
windows-arm): pip install requirements, byte-compile all scripts, import the
LiteRT Interpreter, then run scripts/test_windows_compat.py (stdlib unittest,
no model downloads):
  1. ensure_local link-or-copy fallback with a monkeypatched hf_hub_download
     (incl. forced symlink-privilege failure and forced hardlink failure)
  2. sa3_tflite.py --help + the examples block in fresh interpreters with
     PYTHONUTF8/PYTHONIOENCODING stripped (native console code page)
  3. --play backend dispatch per platform without playing audio
@Cortexelus
Cortexelus merged commit f0dcdd2 into main Jul 14, 2026
9 checks passed
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