-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·107 lines (95 loc) · 3.16 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·107 lines (95 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
# One-time setup for Chapter Reader (macOS primary; Linux supported for dev).
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
echo "=== Chapter Reader setup ==="
# System: espeak-ng (required for Kokoro)
if ! command -v espeak-ng >/dev/null 2>&1 && ! command -v espeak >/dev/null 2>&1; then
if [[ "$(uname -s)" == "Darwin" ]] && command -v brew >/dev/null 2>&1; then
echo "Installing espeak-ng via Homebrew…"
brew install espeak-ng || true
elif command -v apt-get >/dev/null 2>&1; then
echo "Installing espeak-ng via apt…"
sudo apt-get update -qq
sudo apt-get install -y -qq espeak-ng
else
echo "Warning: espeak-ng not found. Install manually (brew install espeak-ng)."
fi
fi
# Prefer CHAPTER_READER_PYTHON, then 3.12 → 3.11 → 3.10 → python3
PY=""
for candidate in "${CHAPTER_READER_PYTHON:-}" python3.12 python3.11 python3.10 python3; do
[[ -z "$candidate" ]] && continue
if command -v "$candidate" >/dev/null 2>&1; then
ver="$("$candidate" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')"
major="${ver%%.*}"
minor="${ver#*.}"
if [[ "$major" -eq 3 && "$minor" -ge 10 && "$minor" -le 12 ]]; then
PY="$candidate"
break
fi
fi
done
CORE_ONLY=0
if [[ -z "$PY" ]]; then
if [[ "${CHAPTER_READER_ALLOW_SAY_ONLY:-}" == "1" ]] && command -v python3 >/dev/null 2>&1; then
PY="python3"
CORE_ONLY=1
echo "👀 Using $($PY --version) without Kokoro — macOS Say / Piper only."
else
echo "Error: need Python 3.10–3.12 for Kokoro."
echo " brew install python@3.12"
echo "Or set CHAPTER_READER_ALLOW_SAY_ONLY=1 for Say-only Mac install."
exit 1
fi
fi
echo "Using $PY ($($PY --version))"
if [[ ! -d .venv ]]; then
if ! "$PY" -m venv .venv 2>/dev/null; then
if command -v apt-get >/dev/null 2>&1; then
echo "Installing python3-venv…"
sudo apt-get install -y -qq "python${PY#python}-venv" || sudo apt-get install -y -qq python3-venv
fi
"$PY" -m venv .venv
fi
fi
# shellcheck source=/dev/null
source .venv/bin/activate
pip install -q --upgrade pip
if [[ "$CORE_ONLY" -eq 1 ]]; then
pip install -q -r requirements-core.txt
else
# Full neural stack; if torch/kokoro fail, still keep the API + Say path alive.
if ! pip install -q -r requirements.txt; then
echo "👀 Full requirements failed — installing core API deps so macOS Say still works."
pip install -q -r requirements-core.txt
CORE_ONLY=1
fi
fi
echo ""
echo "=== Asset discovery ==="
python discover.py || true
if [[ "$CORE_ONLY" -eq 0 ]]; then
echo ""
echo "=== Prefetch Kokoro model (first run may download ~200MB) ==="
python - <<'PY'
import sys
sys.path.insert(0, ".")
try:
from engines.kokoro_engine import prefetch_model
if prefetch_model():
print("Kokoro ready.")
else:
print("Kokoro prefetch skipped (espeak or deps missing).")
except Exception as e:
print(f"Kokoro prefetch note: {e}")
PY
else
echo ""
echo "Skipping Kokoro prefetch (Say-only / core install)."
fi
echo ""
echo "Setup complete."
echo " Mac app (recommended): ./install-mac-app.sh"
echo " Browser UI: ./start.sh"