Skip to content

Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.

test(llama.cpp): validate downloader failure paths

游雁916c175ec916
diff --git a/runtime/llama.cpp/download-funasr-model.sh b/runtime/llama.cpp/download-funasr-model.sh
index 0658a8fdc..fdd6fdc0b 100755
--- a/runtime/llama.cpp/download-funasr-model.sh
+++ b/runtime/llama.cpp/download-funasr-model.sh
@@ -57,7 +57,7 @@ esac
# huggingface_hub ships `hf` (new CLI); older versions only have `huggingface-cli` (deprecated). Use whichever exists.
if command -v hf >/dev/null 2>&1; then HF=hf
elif command -v huggingface-cli >/dev/null 2>&1; then HF=huggingface-cli
-else echo "need the Hugging Face CLI: pip install -U huggingface_hub"; exit 1; fi
+else echo "error: need the Hugging Face CLI: pip install -U huggingface_hub" >&2; exit 1; fi
mkdir -p "$OUT"
echo "downloading $REPO ..."
if [ ${#FILES[@]} -eq 0 ]; then
@@ -69,4 +69,12 @@ if [ "$MODEL" != "fsmn-vad" ] && [ "$MODEL" != "vad" ]; then
echo "downloading FSMN-VAD (for --vad) ..."
"$HF" download FunAudioLLM/fsmn-vad-GGUF fsmn-vad.gguf --local-dir "$OUT"
fi
-echo "done -> $OUT"; ls -1 "$OUT"/*.gguf
+shopt -s nullglob
+GGUF_FILES=("$OUT"/*.gguf)
+shopt -u nullglob
+if [ ${#GGUF_FILES[@]} -eq 0 ]; then
+ echo "error: no GGUF files found in $OUT" >&2
+ exit 1
+fi
+echo "done -> $OUT"
+printf '%s\n' "${GGUF_FILES[@]}"
diff --git a/runtime/llama.cpp/tests/test_download_funasr_model.sh b/runtime/llama.cpp/tests/test_download_funasr_model.sh
index 7c583170c..48bb01b1d 100755
--- a/runtime/llama.cpp/tests/test_download_funasr_model.sh
+++ b/runtime/llama.cpp/tests/test_download_funasr_model.sh
@@ -13,6 +13,10 @@ set -euo pipefail
printf '%s\n' "$*" >>"$HF_LOG"
+if [[ "${HF_SKIP_CREATE:-0}" == 1 ]]; then
+ exit 0
+fi
+
out=
args=("$@")
for ((i = 0; i < ${#args[@]}; i++)); do
@@ -87,4 +91,19 @@ if bash "$SCRIPT" sensevoice "$TMP/out" q4km >/dev/null 2>&1; then
fi
[[ ! -s "$HF_LOG" ]]
+mkdir -p "$TMP/empty-bin"
+if PATH="$TMP/empty-bin" /bin/bash "$SCRIPT" sensevoice "$TMP/out" >"$TMP/stdout" 2>"$TMP/stderr"; then
+ echo "download succeeded without a Hugging Face CLI" >&2
+ exit 1
+fi
+[[ ! -s "$TMP/stdout" ]]
+grep -F "need the Hugging Face CLI" "$TMP/stderr" >/dev/null
+
+reset_case
+if HF_SKIP_CREATE=1 bash "$SCRIPT" sensevoice "$TMP/out" >"$TMP/stdout" 2>"$TMP/stderr"; then
+ echo "download succeeded without producing a GGUF file" >&2
+ exit 1
+fi
+grep -F "no GGUF files found in $TMP/out" "$TMP/stderr" >/dev/null
+
echo "download-funasr-model contract tests passed"