25 lines
1.4 KiB
Bash
Executable File
25 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Quick end-to-end check that Ollama speech works on this Mac. Plays one sentence per installed phonon model.
|
|
set -euo pipefail
|
|
BASE="${OLLAMA_BASE:-http://127.0.0.1:11434}"
|
|
ver=$(curl -fsS "$BASE/api/version" | jq -r .version) || { echo "✗ Ollama not reachable at $BASE"; exit 1; }
|
|
echo "✓ Ollama $ver"
|
|
models=$(curl -fsS "$BASE/api/tags" | jq -r '.models[].name' | grep -E '^phonon' || true)
|
|
[[ -z "$models" ]] && { echo "✗ no phonon model — run: ollama pull phonon"; exit 1; }
|
|
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
|
|
for m in $models; do
|
|
case "$m" in
|
|
*-de*) text="Dies ist ein kurzer Test der deutschen Sprachausgabe." ;;
|
|
*-fr*) text="Ceci est un court test de synthèse vocale." ;;
|
|
*-es*) text="Esta es una breve prueba de síntesis de voz." ;;
|
|
*-pt*) text="Este é um breve teste de síntese de voz." ;;
|
|
*) text="This is a short test of local speech synthesis." ;;
|
|
esac
|
|
start=$(python3 -c 'import time;print(time.time())')
|
|
curl -fsS "$BASE/v1/audio/speech" -H 'Content-Type: application/json' \
|
|
-d "$(jq -nc --arg m "$m" --arg t "$text" '{model:$m,input:$t,voice:"default",response_format:"wav"}')" -o "$tmp/out.wav"
|
|
end=$(python3 -c 'import time;print(time.time())')
|
|
printf '✓ %-28s %6d bytes %.2fs total\n' "$m" "$(wc -c < "$tmp/out.wav")" "$(python3 -c "print($end-$start)")"
|
|
afplay "$tmp/out.wav"
|
|
done
|