Files
2026-07-27 00:33:25 +08:00

80 lines
1.9 KiB
Bash
Executable File

#!/bin/zsh
set -euo pipefail
usage() {
echo "Usage: install_macos.sh --wheel PATH --assets PATH --model-dir PATH [--runtime PATH]"
}
runtime_root="$HOME/Library/Application Support/MPM Local Voice/runtime"
wheel_path=""
assets_path=""
model_source=""
while (( $# )); do
case "$1" in
--runtime)
runtime_root="$2"
shift 2
;;
--wheel)
wheel_path="$2"
shift 2
;;
--assets)
assets_path="$2"
shift 2
;;
--model-dir)
model_source="$2"
shift 2
;;
*)
usage
exit 2
;;
esac
done
if [[ -z "$wheel_path" || -z "$assets_path" || -z "$model_source" ]]; then
usage
exit 2
fi
for required in "$wheel_path" "$assets_path" "$model_source"; do
if [[ ! -e "$required" ]]; then
echo "Missing required input: $required" >&2
exit 2
fi
done
if ! command -v python3.11 >/dev/null 2>&1; then
echo "Python 3.11 is required. Install it with Homebrew first." >&2
exit 2
fi
if ! command -v ffmpeg >/dev/null 2>&1; then
echo "ffmpeg is required and must be available on PATH." >&2
exit 2
fi
if ! command -v whisper >/dev/null 2>&1; then
echo "Whisper is required and must be available on PATH." >&2
exit 2
fi
mkdir -p "$runtime_root/models" "$runtime_root/jobs" "$runtime_root/wheels"
python3.11 -m venv "$runtime_root/.venv"
"$runtime_root/.venv/bin/python" -m pip install --upgrade pip
cp -p "$wheel_path" "$runtime_root/wheels/"
"$runtime_root/.venv/bin/python" -m pip install "$wheel_path"
"$runtime_root/.venv/bin/python" -m pip install numpy==2.4.6 soundfile==0.14.0
tar -xzf "$assets_path" -C "$runtime_root"
model_target="$runtime_root/models/CosyVoice3-0.5B-Candle"
mkdir -p "$model_target"
rsync -a "$model_source/" "$model_target/"
echo "Runtime installed at: $runtime_root"
echo "Run scripts/verify_install.py with:"
echo "\"$runtime_root/.venv/bin/python\" scripts/verify_install.py --runtime-root \"$runtime_root\" --device metal"