azemari / install_kaggle.sh
lab.et
Fix inference packaging: public indextts imports, add infer_azemari.py and install_kaggle.sh
1412013
Raw History Blame Contribute Delete
2.47 kB
#!/usr/bin/env bash
# Azemari setup — Kaggle, Colab, or a local GPU box.
#
# Fixes the published packaging bug: model_v2.py in the model repo imported the
# internal fork namespace `indextts_ethiopic`, which is not published. The public
# IndexTTS-2.5 codebase uses `indextts`. We patch the two files in place.
#
# Usage:
# bash install_kaggle.sh [/path/to/workdir]
# MODEL_DIR=./azemari bash install_kaggle.sh
set -euo pipefail
WORK="${1:-${WORK:-/kaggle/working}}"
AZ="${MODEL_DIR:-$WORK/azemari}"
REPO="$WORK/index-tts"
PIN=a371df7d0746a0ae7fdf075798b6b04e34a0132e # IndexTTS-2.5 commit Azemari was trained against
mkdir -p "$WORK"
echo "==> 1/4 code @ ${PIN:0:7}"
if [ ! -d "$REPO/.git" ]; then
git init -q "$REPO"
git -C "$REPO" remote add origin https://github.com/index-tts/index-tts
fi
git -C "$REPO" fetch -q --depth 1 origin "$PIN"
git -C "$REPO" checkout -q FETCH_HEAD
pip install -q -e "$REPO"
echo "==> 2/4 weights -> $AZ"
python - "$AZ" <<'PY'
import sys, os
from huggingface_hub import snapshot_download
dest = sys.argv[1]
snapshot_download("Lab-et/azemari", local_dir=dest,
allow_patterns=["*.pth", "*.pt", "*.yaml", "*.py", "*.json", "*.tiktoken", "*.jinja", "*.txt", "*.md"])
print("downloaded:", dest)
PY
echo "==> 3/4 patch model_v2 + tokenizer"
cp "$AZ/tokenizer_ethiopic.py" "$REPO/indextts/utils/tokenizer.py"
python - "$AZ" "$REPO" <<'PY'
import sys, pathlib
az, repo = map(pathlib.Path, sys.argv[1:3])
src = (az / "model_v2.py").read_text(encoding="utf-8")
assert "indextts_ethiopic" in src, "unexpected model_v2.py: fork imports not found"
out = src.replace("indextts_ethiopic", "indextts")
(repo / "indextts/gpt/model_v2.py").write_text(out, encoding="utf-8")
print("patched", repo / "indextts/gpt/model_v2.py")
PY
echo "==> 4/4 verify"
cd "$REPO"
python - <<'PY'
from indextts.utils.tokenizer import LANGUAGE_DICT
from indextts.gpt.model_v2 import UnifiedVoice
missing = [l for l in ("am", "om", "ti") if l not in LANGUAGE_DICT]
assert not missing, f"tokenizer patch incomplete: {missing}"
print("ok — languages:", ", ".join(l for l in ("am", "om", "ti") if l in LANGUAGE_DICT))
PY
cat <<EOF
Done.
Next:
cd $REPO
python $WORK/azemari/infer_azemari.py --model-dir $AZ --ref voice.wav \\
--text "ሰላም፣ እንዴት ነህ?" --lang am --emotion calm --out line.wav
First run fetches w2v-bert-2.0, CAMPPlus and BigVGAN into $AZ/hf_cache (~2.4 GB).
Kaggle: Settings -> Internet -> On.
EOF