#!/data/data/com.termux/files/usr/bin/bash # Pull RVC .bin files from Qualcomm AI Hub Workbench # No time limit - run as a script set -u PROJECT_ROOT="/data/data/com.termux/files/home/projects/rvc_npu" MODELS_DIR="$PROJECT_ROOT/models" LOG="/data/data/com.termux/files/home/tmp/rvc_pull_bins.log" mkdir -p "$MODELS_DIR/hubert" "$MODELS_DIR/rmvpe" "$MODELS_DIR/synthesizer" mkdir -p "$(dirname "$LOG")" log() { echo "[$(date +%H:%M:%S)] $*" | tee -a "$LOG"; } log "=== RVC .bin pull started ===" log "Project root: $PROJECT_ROOT" log "Models dir: $MODELS_DIR" cd "$PROJECT_ROOT" || exit 1 python3 - <<'PY' 2>&1 | tee -a "$LOG" import os, sys, time, json import qai_hub as hub PROJECT_ROOT = "/data/data/com.termux/files/home/projects/rvc_npu" MODELS_DIR = f"{PROJECT_ROOT}/models" LOG = "/data/data/com.termux/files/home/tmp/rvc_pull_bins.log" def log(msg): line = f"[{time.strftime('%H:%M:%S')}] {msg}" print(line, flush=True) with open(LOG, "a") as f: f.write(line + "\n") # ---------- 1) DOWNLOAD THE 3 KNOWN .bin ---------- known = [ ('mn7gg08on', 'synthesizer/flowreverse_s23.bin'), # ~12.6 MB ('mngjj46rn', 'synthesizer/encflow_s23.bin'), # unknown size ] for mid, rel in known: target = f"{MODELS_DIR}/{rel}" if os.path.exists(target) and os.path.getsize(target) > 1024 * 1024: log(f"[SKIP] {rel} already exists ({os.path.getsize(target)//1024//1024} MB)") continue log(f"[GET ] {mid} -> {rel}") t0 = time.time() try: m = hub.get_model(mid) log(f" name={m.name} type={m.model_type} size~?") path = m.download(filename=target) sz = os.path.getsize(path) if path and os.path.exists(path) else 0 log(f" OK {path} ({sz//1024} KB in {time.time()-t0:.1f}s)") except Exception as e: log(f" ERR {mid}: {e}") # ---------- 2) SCAN 600+ COMPILE JOBS to find hubert/rmvpe ---------- log("=== Scanning 600 compile jobs to find hubert/rmvpe ===") from qai_hub import JobType candidates = [] seen_jids = set() for off in range(0, 600, 100): try: summaries = hub.get_job_summaries(limit=100, offset=off, type=JobType.COMPILE) except Exception as e: log(f" offset {off}: {e}") continue for s in summaries: # summary has .name, .job_id, etc. name = (getattr(s, "name", "") or "").lower() jid = getattr(s, "job_id", None) or getattr(s, "id", None) if not jid or jid in seen_jids: continue seen_jids.add(jid) if any(k in name for k in ("hubert", "rmvpe", "e2e_320", "320ms")): candidates.append((jid, getattr(s, "name", ""), getattr(s, "state", "?"))) log(f" CAND {jid} state={getattr(s,'state','?')} name={getattr(s,'name','')}") log(f"Total compile job candidates with hubert/rmvpe: {len(candidates)}") # ---------- 3) For each candidate, fetch full job and read source model name ---------- for jid, nm, st in candidates: try: j = hub.get_job(jid) except Exception as e: log(f" full {jid}: {e}") continue src = j.model # the SOURCE model (ONNX), not the .bin try: sm = hub.get_model(src) log(f" JOB {jid} state={j.state} src.model_id={sm.model_id} src.name={sm.name} src.url={sm.url}") except Exception as e: log(f" src for {jid}: {e}") # Check if this compile job has produced a .bin (it would be a QNN_CONTEXT_BINARY model attribute) if hasattr(j, "output_model") and j.output_model: try: om = hub.get_model(j.output_model) log(f" -> output .bin model_id={om.model_id} name={om.name}") except Exception as e: log(f" output .bin read err: {e}") elif hasattr(j, "target_model") and j.target_model: log(f" target_model={j.target_model}") # Also try direct lookup: search by model name via hub.list_models if exists log("=== Direct model search via get_model with substring ===") for sub in ("hubert", "rmvpe"): try: # try get_model on common hash patterns? not possible without id # try fetching by guessing suffixes (won't work) log(f" {sub}: no direct lookup API; rely on job scan above") except Exception as e: log(f" {sub}: {e}") log("=== DONE ===") PY log "=== script finished ==="