mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-15 12:50:42 -07:00
The distributed macOS aarch64 binary shipped without MLX acceleration despite the model and backend code supporting it. Two root causes: 1. **OSError not caught in platform_detect.py** PyInstaller bundles isolate the filesystem, so when MLX tries to load its Metal shader libraries (.metallib) it raises OSError, not ImportError. platform_detect.get_backend_type() only caught ImportError, causing a silent fallback to PyTorch even on Apple Silicon hardware. Fix: broaden the except clause to (ImportError, OSError, RuntimeError) and import mlx.core instead of mlx (forces native lib loading eagerly). 2. **collect_data_files used instead of collect_all for MLX** build_binary.py and voicebox-server.spec used --collect-data / collect_data_files for mlx and mlx_audio. This copies Python source and pure-Python data, but NOT native shared libraries (.dylib, .metallib). Fix: switch to --collect-all / collect_all which captures binaries too, then pass them to Analysis(binaries=...) in the spec. Result: macOS Apple Silicon users now get MLX inference (~4-5x faster than PyTorch CPU), matching the performance documented in the README.
58 lines
2.3 KiB
RPMSpec
58 lines
2.3 KiB
RPMSpec
# -*- mode: python ; coding: utf-8 -*-
|
|
from PyInstaller.utils.hooks import collect_data_files
|
|
from PyInstaller.utils.hooks import collect_submodules
|
|
from PyInstaller.utils.hooks import copy_metadata
|
|
|
|
datas = []
|
|
hiddenimports = ['backend', 'backend.main', 'backend.config', 'backend.database', 'backend.models', 'backend.profiles', 'backend.history', 'backend.tts', 'backend.transcribe', 'backend.platform_detect', 'backend.backends', 'backend.backends.pytorch_backend', 'backend.utils.audio', 'backend.utils.cache', 'backend.utils.progress', 'backend.utils.hf_progress', 'backend.utils.validation', 'torch', 'transformers', 'fastapi', 'uvicorn', 'sqlalchemy', 'librosa', 'soundfile', 'qwen_tts', 'qwen_tts.inference', 'qwen_tts.inference.qwen3_tts_model', 'qwen_tts.inference.qwen3_tts_tokenizer', 'qwen_tts.core', 'qwen_tts.cli', 'pkg_resources.extern', 'backend.backends.mlx_backend', 'mlx', 'mlx.core', 'mlx.nn', 'mlx_audio', 'mlx_audio.tts', 'mlx_audio.stt']
|
|
datas += collect_data_files('qwen_tts')
|
|
# Use collect_all (not collect_data_files) so native .dylib and .metallib
|
|
# files are bundled as binaries, not data. Without this, MLX raises OSError
|
|
# when loading Metal shaders inside the PyInstaller bundle.
|
|
from PyInstaller.utils.hooks import collect_all as _collect_all
|
|
_mlx_datas, _mlx_bins, _mlx_hidden = _collect_all('mlx')
|
|
_mlxa_datas, _mlxa_bins, _mlxa_hidden = _collect_all('mlx_audio')
|
|
datas += _mlx_datas + _mlxa_datas
|
|
datas += copy_metadata('qwen-tts')
|
|
hiddenimports += collect_submodules('qwen_tts')
|
|
hiddenimports += collect_submodules('jaraco')
|
|
hiddenimports += collect_submodules('mlx')
|
|
hiddenimports += collect_submodules('mlx_audio')
|
|
|
|
|
|
a = Analysis(
|
|
['server.py'],
|
|
pathex=[],
|
|
binaries=_mlx_bins + _mlxa_bins,
|
|
datas=datas,
|
|
hiddenimports=hiddenimports,
|
|
hookspath=[],
|
|
hooksconfig={},
|
|
runtime_hooks=[],
|
|
excludes=[],
|
|
noarchive=False,
|
|
optimize=0,
|
|
)
|
|
pyz = PYZ(a.pure)
|
|
|
|
exe = EXE(
|
|
pyz,
|
|
a.scripts,
|
|
a.binaries,
|
|
a.datas,
|
|
[],
|
|
name='voicebox-server',
|
|
debug=False,
|
|
bootloader_ignore_signals=False,
|
|
strip=False,
|
|
upx=True,
|
|
upx_exclude=[],
|
|
runtime_tmpdir=None,
|
|
console=True,
|
|
disable_windowed_traceback=False,
|
|
argv_emulation=False,
|
|
target_arch=None,
|
|
codesign_identity=None,
|
|
entitlements_file=None,
|
|
)
|