huanx commited on
Commit
4adea97
·
verified ·
1 Parent(s): 058fb28

Fix: use huggingface_hub to download models (xet compatible)

Browse files
Files changed (1) hide show
  1. start.sh +32 -42
start.sh CHANGED
@@ -26,6 +26,7 @@ download_if_missing() {
26
 
27
  HF_BASE="https://huggingface.co/lj1995/GPT-SoVITS/resolve/main"
28
  FASTTEXT_LID_URL="https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin"
 
29
  download_if_missing "$HF_BASE/chinese-roberta-wwm-ext-large/config.json" "$PM_DIR/chinese-roberta-wwm-ext-large/config.json"
30
  download_if_missing "$HF_BASE/chinese-roberta-wwm-ext-large/pytorch_model.bin" "$PM_DIR/chinese-roberta-wwm-ext-large/pytorch_model.bin"
31
  download_if_missing "$HF_BASE/chinese-roberta-wwm-ext-large/tokenizer.json" "$PM_DIR/chinese-roberta-wwm-ext-large/tokenizer.json"
@@ -37,16 +38,27 @@ download_if_missing "$HF_BASE/v2Pro/s2Gv2ProPlus.pth" "$PM_DIR/v2Pro/s2Gv2ProPlu
37
  download_if_missing "$HF_BASE/sv/pretrained_eres2netv2w24s4ep4.ckpt" "$PM_DIR/sv/pretrained_eres2netv2w24s4ep4.ckpt"
38
  download_if_missing "$FASTTEXT_LID_URL" "$PM_DIR/fast_langdetect/lid.176.bin"
39
 
40
- # Download Aemeath (爱弥斯) custom character models
41
  CHAR_DIR="/data/models"
42
  mkdir -p "$CHAR_DIR"
43
 
44
- CHAR_BASE="https://huggingface.co/spaces/huanx/gpt-sovits/resolve/main"
45
- download_if_missing "$CHAR_BASE/aimisi-e16.ckpt" "$CHAR_DIR/aimisi-e16.ckpt"
46
- download_if_missing "$CHAR_BASE/aimisi_e10_s180.pth" "$CHAR_DIR/aimisi_e10_s180.pth"
 
 
 
 
47
 
48
- REF_BASE="https://huggingface.co/spaces/huanx/gpt-sovits/resolve/main"
49
- download_if_missing "$REF_BASE/zh_vo_MAIN_YHX_2_12.wav" "$CHAR_DIR/zh_vo_MAIN_YHX_2_12.wav"
 
 
 
 
 
 
 
50
 
51
  echo "Pretrained: $(find "$PM_DIR" -type f | wc -l) files"
52
  echo "Character: $(find "$CHAR_DIR" -type f | wc -l) files"
@@ -77,47 +89,25 @@ VITS_WEIGHTS="$PM_DIR/v2Pro/s2Gv2ProPlus.pth"
77
  if [ -s "$CHAR_DIR/aimisi-e16.ckpt" ] && [ -s "$CHAR_DIR/aimisi_e10_s180.pth" ]; then
78
  T2S_WEIGHTS="$CHAR_DIR/aimisi-e16.ckpt"
79
  VITS_WEIGHTS="$CHAR_DIR/aimisi_e10_s180.pth"
 
 
 
80
  fi
81
 
82
- cat > "$CFG_PATH" <<EOF
83
  custom:
84
- bert_base_path: GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large
85
- cnhuhbert_base_path: GPT_SoVITS/pretrained_models/chinese-hubert-base
86
  device: cpu
87
  is_half: false
88
  t2s_weights_path: $T2S_WEIGHTS
89
  version: v2ProPlus
90
  vits_weights_path: $VITS_WEIGHTS
91
- EOF
92
-
93
- echo "Using GPT weights: $T2S_WEIGHTS"
94
- echo "Using SoVITS weights: $VITS_WEIGHTS"
95
-
96
- # Force CPU
97
- export CUDA_VISIBLE_DEVICES=""
98
- export DEVICE="cpu"
99
- export FTLANG_CACHE="$PM_DIR/fast_langdetect"
100
- export SPACE_TTS_CONFIG="GPT_SoVITS/configs/tts_infer_cpu.yaml"
101
- export NLTK_DATA="/usr/local/nltk_data"
102
-
103
- mkdir -p "$NLTK_DATA"
104
- python - <<'PY'
105
- import nltk
106
- packages = {
107
- "averaged_perceptron_tagger_eng": "taggers/averaged_perceptron_tagger_eng",
108
- "averaged_perceptron_tagger": "taggers/averaged_perceptron_tagger",
109
- "cmudict": "corpora/cmudict",
110
- }
111
- for pkg, resource_path in packages.items():
112
- try:
113
- nltk.data.find(resource_path)
114
- except LookupError:
115
- try:
116
- nltk.download(pkg, download_dir="/usr/local/nltk_data", quiet=True)
117
- except Exception as exc:
118
- print(f"WARN: failed to download NLTK package {pkg}: {exc}")
119
- PY
120
-
121
- # Start Space UI + API
122
- echo "Starting Space UI on 0.0.0.0:7860..."
123
- exec python -m uvicorn ui:app --host 0.0.0.0 --port 7860
 
26
 
27
  HF_BASE="https://huggingface.co/lj1995/GPT-SoVITS/resolve/main"
28
  FASTTEXT_LID_URL="https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin"
29
+
30
  download_if_missing "$HF_BASE/chinese-roberta-wwm-ext-large/config.json" "$PM_DIR/chinese-roberta-wwm-ext-large/config.json"
31
  download_if_missing "$HF_BASE/chinese-roberta-wwm-ext-large/pytorch_model.bin" "$PM_DIR/chinese-roberta-wwm-ext-large/pytorch_model.bin"
32
  download_if_missing "$HF_BASE/chinese-roberta-wwm-ext-large/tokenizer.json" "$PM_DIR/chinese-roberta-wwm-ext-large/tokenizer.json"
 
38
  download_if_missing "$HF_BASE/sv/pretrained_eres2netv2w24s4ep4.ckpt" "$PM_DIR/sv/pretrained_eres2netv2w24s4ep4.ckpt"
39
  download_if_missing "$FASTTEXT_LID_URL" "$PM_DIR/fast_langdetect/lid.176.bin"
40
 
41
+ # Download Aemeath custom character models using huggingface_hub (handles xet storage)
42
  CHAR_DIR="/data/models"
43
  mkdir -p "$CHAR_DIR"
44
 
45
+ echo "Downloading character models via huggingface_hub..."
46
+ python3 -c "
47
+ from huggingface_hub import hf_hub_download
48
+ import os
49
+
50
+ char_dir = '$CHAR_DIR'
51
+ repo = 'huanx/gpt-sovits'
52
 
53
+ for fname in ['aimisi-e16.ckpt', 'aimisi_e10_s180.pth', 'zh_vo_MAIN_YHX_2_12.wav']:
54
+ dest = os.path.join(char_dir, fname)
55
+ if not os.path.exists(dest) or os.path.getsize(dest) < 1000:
56
+ print(f'Downloading {fname}...')
57
+ hf_hub_download(repo_id=repo, filename=fname, local_dir=char_dir, repo_type='space')
58
+ print(f' -> {os.path.getsize(dest)} bytes')
59
+ else:
60
+ print(f'{fname} already exists ({os.path.getsize(dest)} bytes)')
61
+ "
62
 
63
  echo "Pretrained: $(find "$PM_DIR" -type f | wc -l) files"
64
  echo "Character: $(find "$CHAR_DIR" -type f | wc -l) files"
 
89
  if [ -s "$CHAR_DIR/aimisi-e16.ckpt" ] && [ -s "$CHAR_DIR/aimisi_e10_s180.pth" ]; then
90
  T2S_WEIGHTS="$CHAR_DIR/aimisi-e16.ckpt"
91
  VITS_WEIGHTS="$CHAR_DIR/aimisi_e10_s180.pth"
92
+ echo "Using Aemeath custom models"
93
+ else
94
+ echo "WARN: Aemeath models not found, using default pretrained"
95
  fi
96
 
97
+ cat > "$CFG_PATH" << EOFCFG
98
  custom:
99
+ bert_base_path: $PM_DIR/chinese-roberta-wwm-ext-large
100
+ cnhuhbert_base_path: $PM_DIR/chinese-hubert-base
101
  device: cpu
102
  is_half: false
103
  t2s_weights_path: $T2S_WEIGHTS
104
  version: v2ProPlus
105
  vits_weights_path: $VITS_WEIGHTS
106
+ EOFCFG
107
+
108
+ echo "Config written to $CFG_PATH"
109
+ cat "$CFG_PATH"
110
+
111
+ # Launch UI
112
+ echo "Starting GPT-SoVITS UI on port 7860..."
113
+ exec python3 ui.py