| #!/usr/bin/env bash |
| set -euo pipefail |
|
|
| ip="${1:-127.0.0.1}" |
| port="${2:-8080}" |
| out_dir="${3:-/tmp/tts_smoke}" |
|
|
| mkdir -p "$out_dir" |
|
|
| post_json() { |
| local name="$1" |
| local json="$2" |
| local out="$3" |
| local code="000" |
|
|
| if command -v curl >/dev/null 2>&1; then |
| code=$(curl -s -o "$out" -w '%{http_code}' \ |
| -H 'Content-Type: application/json' \ |
| -d "$json" \ |
| "http://${ip}:${port}/v1/audio/speech") |
| elif command -v wget >/dev/null 2>&1; then |
| wget -q -O "$out" --server-response \ |
| --header='Content-Type: application/json' \ |
| --post-data="$json" \ |
| "http://${ip}:${port}/v1/audio/speech" 2>&1 | awk '/^ HTTP/{code=$2} END{print code}' > /tmp/.tts_http_code |
| if [[ -s /tmp/.tts_http_code ]]; then |
| code=$(cat /tmp/.tts_http_code) |
| fi |
| else |
| echo "No curl or wget found" |
| return 1 |
| fi |
|
|
| echo "$name http:$code size:$(stat -c%s "$out" 2>/dev/null || echo 0)" |
| if [[ "$code" == "200" ]]; then |
| [[ -s "$out" ]] || { echo "$name output empty"; return 1; } |
| fi |
| } |
|
|
| echo "== TTS smoke test ==" |
| echo "target: ${ip}:${port}" |
| echo "out: ${out_dir}" |
|
|
| |
| post_json "en_ok" \ |
| '{"model":"kokoro","input":"Hello world","voice":"af_heart","response_format":"wav","speed":1.0,"instructions":"en"}' \ |
| "${out_dir}/en.wav" |
|
|
| |
| post_json "zh_ok" \ |
| '{"model":"kokoro","input":"ๆฉไธๅฅฝ๏ผไปๅคฉๅคฉๆฐไธ้ใ","voice":"zf_xiaobei","response_format":"wav","speed":1.0,"instructions":"zh"}' \ |
| "${out_dir}/zh.wav" |
|
|
| |
| post_json "ja_kana_ok" \ |
| '{"model":"kokoro","input":"ใใฏใใใใใใพใใใใใใฏใใใฆใใใงใใญใ","voice":"jf_gongitsune","response_format":"wav","speed":1.0,"instructions":"ja"}' \ |
| "${out_dir}/ja_kana.wav" |
|
|
| |
| post_json "ja_katakana_ok" \ |
| '{"model":"kokoro","input":"ใณใณใใใใใจใญใทใฏใชใใฌใคใทใในใ","voice":"jf_gongitsune","response_format":"wav","speed":1.0,"instructions":"ja"}' \ |
| "${out_dir}/ja_katakana.wav" |
|
|
| |
| post_json "ja_kana_long_ok" \ |
| '{"model":"kokoro","input":"ใใฏใใใใใใพใใใใใใฏใใใฆใใใงใใญใใใใใฎใใใใฏใใใใใ
ใใใใใฏใใพใใพใใใใใใใฎใฒใใใคใใใใซใใใฆใใพใใ","voice":"jf_gongitsune","response_format":"wav","speed":1.0,"instructions":"ja"}' \ |
| "${out_dir}/ja_kana_long.wav" |
|
|
| |
| post_json "ja_kanji_reject" \ |
| '{"model":"kokoro","input":"ใใฏใใใใใใพใใไปๆฅใฏ่ฏใๅคฉๆฐใงใใญใ","voice":"jf_gongitsune","response_format":"wav","speed":1.0,"instructions":"ja"}' \ |
| "${out_dir}/ja_kanji.err" |
|
|
| echo "done" |
|
|