fix: always use --no-deps for kokoro to avoid numpy/spacy conflicts
kokoro pins numpy==1.26.4 but scipy 1.16+ needs numpy>=2.0, and misaki[en] pulls spacy-curated-transformers which needs spacy 4.x (unreleased). Both work fine at runtime with numpy 2.x. Removed the two-attempt strategy in favor of always installing kokoro with --no-deps and manually installing only the runtime deps not already covered by requirements.txt. This prevents the numpy tug-of-war between base requirements and TTS backends. https://claude.ai/code/session_01965m1v3f1cK6gDV1JHioA8
+21 −41 · 1 file changed
-
scripts/install.sh+21 −41
@@ -457,58 +457,38 @@ install_kokoro() { echo -e "${GREEN}✓ espeak-ng already installed${NC}" fi - # kokoro → misaki[en] → spacy-curated-transformers → spacy>=4.0.0dev - # spacy 4 doesn't exist as a stable release yet, so pip tries to build - # 4.0.0.dev3 from source which fails. + # kokoro has two unresolvable pip conflicts: + # 1) kokoro pins numpy==1.26.4, but scipy 1.16+ needs numpy>=2.0 + # 2) misaki[en] → spacy-curated-transformers → spacy>=4.0.0dev (doesn't exist) # - # Strategy: - # 1) Try normal pip install with a constraint pinning spacy<4. - # 2) If that fails (spacy-curated-transformers needs spacy 4), fall back - # to --no-deps for kokoro and install its runtime deps manually, - # skipping spacy-curated-transformers (espeak-ng handles English G2P). + # Both chatterbox-tts and kokoro work fine at runtime with numpy 2.x; + # the pins are overly strict metadata. We always use --no-deps and + # manually install only the runtime deps that aren't already present. KOKORO_INSTALLED=false - # --- Attempt 1: Normal install with spacy<4 constraint --- - echo -e "${YELLOW} Attempting normal install (constraining spacy<4)...${NC}" - CONSTRAINTS=$(mktemp) - echo "spacy<4.0.0" > "$CONSTRAINTS" - $PYTHON_CMD -m pip install kokoro soundfile -c "$CONSTRAINTS" 2>/dev/null && { + echo -e "${BLUE} Installing kokoro (--no-deps to avoid numpy/spacy conflicts)...${NC}" + $PYTHON_CMD -m pip install kokoro --no-deps --quiet 2>/dev/null + # Runtime deps not already covered by requirements.txt: + # loguru — kokoro's logger + # misaki — G2P (grapheme-to-phoneme); skip [en] extra to avoid + # spacy-curated-transformers which needs spacy 4 + # num2words — number → word expansion (English G2P) + # phonemizer — espeak-ng wrapper for phonemization + # soundfile — WAV I/O + # Already in requirements.txt: torch, numpy, scipy, transformers, huggingface-hub + $PYTHON_CMD -m pip install loguru soundfile "misaki>=0.7.4" num2words phonemizer --quiet 2>/dev/null + + if $PYTHON_CMD -c "from kokoro import KPipeline" 2>/dev/null; then KOKORO_INSTALLED=true echo -e "${GREEN}✓ Kokoro TTS installed${NC}" - } - rm -f "$CONSTRAINTS" - - # --- Attempt 2: Manual dep install, skip conflicting spacy-curated-transformers --- - if [ "$KOKORO_INSTALLED" = false ]; then - echo -e "${YELLOW} Normal install failed. Installing with manual dependency management...${NC}" - # Install kokoro itself without resolving transitive deps - $PYTHON_CMD -m pip install kokoro --no-deps --quiet 2>/dev/null - # Install its direct runtime deps (torch/numpy/scipy/transformers already present) - $PYTHON_CMD -m pip install loguru soundfile --quiet 2>/dev/null - # Install misaki without the [en] extra first (base G2P) - $PYTHON_CMD -m pip install "misaki>=0.7.4" --quiet 2>/dev/null - # Install English G2P extras that don't conflict - $PYTHON_CMD -m pip install num2words phonemizer --quiet 2>/dev/null - # Verify it actually loads - if $PYTHON_CMD -c "from kokoro import KPipeline" 2>/dev/null; then - KOKORO_INSTALLED=true - echo -e "${GREEN}✓ Kokoro TTS installed (without spacy-curated-transformers)${NC}" - echo -e "${BLUE} Note: English G2P uses espeak-ng as the phonemizer backend.${NC}" - fi - fi - - if [ "$KOKORO_INSTALLED" = false ]; then + echo -e "${BLUE} Note: English G2P uses espeak-ng as the phonemizer backend.${NC}" + else echo -e "${RED}✗ Failed to install Kokoro TTS${NC}" echo -e "${BLUE} You can try manually:${NC}" echo -e "${BLUE} $PYTHON_CMD -m pip install kokoro --no-deps${NC}" echo -e "${BLUE} $PYTHON_CMD -m pip install loguru soundfile 'misaki>=0.7.4' num2words phonemizer${NC}" fi - - # Final verification - $PYTHON_CMD -c "from kokoro import KPipeline; print(' ✓ Kokoro import verified')" 2>/dev/null || { - echo -e "${YELLOW} ⚠ Kokoro import test failed.${NC}" - } echo }