41 lines
2.2 KiB
Bash
Executable File
41 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Records real Ollama responses into test fixtures (T1.1). Requires a running Ollama ≥ 0.40.9.
|
|
# Usage: scripts/capture-fixtures.sh [base_url]
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
BASE="${1:-http://127.0.0.1:11434}"
|
|
OUT="Packages/VorleserKit/Tests/VorleserOllamaTests/Fixtures"
|
|
mkdir -p "$OUT"
|
|
j() { curl -sS -H 'Content-Type: application/json' "$@"; }
|
|
|
|
echo "→ version / tags"
|
|
j "$BASE/api/version" | tee "$OUT/version.json" | jq -c .
|
|
j "$BASE/api/tags" > "$OUT/tags.json"
|
|
|
|
models=$(jq -r '.models[].name' "$OUT/tags.json" | grep -E '^phonon' || true)
|
|
[[ -z "$models" ]] && { echo "No phonon models installed. Run: ollama pull phonon" >&2; exit 1; }
|
|
|
|
for m in $models; do
|
|
safe=${m//[:\/]/_}
|
|
echo "→ show $m"
|
|
j -X POST "$BASE/api/show" -d "{\"model\":\"$m\"}" \
|
|
| jq '{capabilities, voices, details, model_info: (.model_info // {} | with_entries(select(.key|test("general\\."))))}' \
|
|
> "$OUT/show-$safe.json"
|
|
echo " voices: $(jq -c '.voices' "$OUT/show-$safe.json" | cut -c1-160)"
|
|
echo "→ speech $m"
|
|
curl -sS -D "$OUT/speech-$safe-short.headers" -o "$OUT/speech-$safe-short.pcm" \
|
|
-H 'Content-Type: application/json' "$BASE/v1/audio/speech" \
|
|
-d "{\"model\":\"$m\",\"input\":\"Ready.\",\"voice\":\"default\",\"response_format\":\"pcm\"}"
|
|
echo " bytes: $(wc -c < "$OUT/speech-$safe-short.pcm")"
|
|
done
|
|
|
|
first=$(echo "$models" | head -1)
|
|
echo "→ error cases"
|
|
status() { curl -sS -o "$2" -w '%{http_code}' -H 'Content-Type: application/json' "$BASE/v1/audio/speech" -d "$1"; }
|
|
echo " unknown voice: $(status "{\"model\":\"$first\",\"input\":\"x\",\"voice\":\"NoSuchVoice\",\"response_format\":\"pcm\"}" "$OUT/error-unknown-voice.json")"
|
|
echo " missing model: $(status '{"model":"phonon:does-not-exist","input":"x","voice":"default","response_format":"pcm"}' "$OUT/error-missing-model.json")"
|
|
echo " unsupported option: $(status "{\"model\":\"$first\",\"input\":\"x\",\"voice\":\"default\",\"speed\":1.5}" "$OUT/error-unsupported-option.json")"
|
|
echo " unsupported format: $(status "{\"model\":\"$first\",\"input\":\"x\",\"response_format\":\"mp3\"}" "$OUT/error-unsupported-format.json")"
|
|
|
|
echo "Done. Review $OUT, then update the VERIFY items in docs/OLLAMA_SPEECH_API.md (status codes printed above)."
|