Skip to content

Commit 30a48f6

Browse files
committed
test: Fix test-audio.sh Argument list too long error by replacing inline payload with payload.json and 1s synthetic sine wave
1 parent cf7f4d7 commit 30a48f6

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

tests/test-audio.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,28 @@ fi
5959

6060
# ── Test ALM ──────────────────────────────────────────────────────────
6161
mkdir -p /tmp/audio_test
62-
curl -sL "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" -o /tmp/audio_test/test.mp3
63-
afconvert -f WAVE -d LEI16 /tmp/audio_test/test.mp3 /tmp/audio_test/test.wav
62+
63+
cat << 'EOF' > /tmp/audio_test/gen.py
64+
import wave, struct, math
65+
with wave.open('/tmp/audio_test/test.wav', 'w') as w:
66+
w.setnchannels(1)
67+
w.setsampwidth(2)
68+
w.setframerate(16000)
69+
for i in range(16000):
70+
v = int(math.sin(i * 440.0 * 2.0 * math.pi / 16000.0) * 10000.0)
71+
w.writeframes(struct.pack('<h', v))
72+
EOF
73+
python3 /tmp/audio_test/gen.py
74+
6475
BASE64_AUDIO=$(base64 -i /tmp/audio_test/test.wav | tr -d '\n')
6576

77+
cat <<EOF > /tmp/audio_test/payload.json
78+
{"model":"$MODEL","max_tokens":100,"messages":[{"role":"user","content":[{"type":"text","text":"Transcribe this audio strictly."},{"type":"input_audio","input_audio":{"data":"${BASE64_AUDIO}","format":"wav"}}]}]}
79+
EOF
80+
6681
COMPLETION=$(curl -sf -X POST "$URL/v1/chat/completions" \
6782
-H "Content-Type: application/json" \
68-
-d "{\"model\":\"$MODEL\",\"max_tokens\":100,\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"Transcribe this audio strictly.\"},{\"type\":\"input_audio\",\"input_audio\":{\"data\":\"${BASE64_AUDIO}\",\"format\":\"wav\"}}]}]}")
83+
-d @"/tmp/audio_test/payload.json")
6984

7085
if echo "$COMPLETION" | jq -e '.choices[0].message.content' >/dev/null 2>&1; then
7186
CONTENT=$(echo "$COMPLETION" | jq -r '.choices[0].message.content')

0 commit comments

Comments
 (0)