28 lines
847 B
Bash
28 lines
847 B
Bash
#!/bin/bash
|
|
# TTS synthesis test
|
|
curl -v -o /tmp/test_tts.wav \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"input":"Hello world, this is a test of the text to speech engine.","voice":"Vivian"}' \
|
|
http://localhost:8072/v1/audio/speech 2>&1
|
|
|
|
echo "---"
|
|
if [ -f /tmp/test_tts.wav ]; then
|
|
ls -la /tmp/test_tts.wav
|
|
file /tmp/test_tts.wav 2>/dev/null || echo "(file cmd not found)"
|
|
python3 -c "
|
|
import struct
|
|
with open('/tmp/test_tts.wav','rb') as f:
|
|
hdr = f.read(44)
|
|
if hdr[:4] == b'RIFF':
|
|
sz = struct.unpack('<I', hdr[4:8])[0]
|
|
fmt = hdr[8:12]
|
|
ch = struct.unpack('<H', hdr[22:24])[0]
|
|
sr = struct.unpack('<I', hdr[24:28])[0]
|
|
print(f'WAV: size={sz+8}, channels={ch}, sample_rate={sr}')
|
|
else:
|
|
print(f'Not WAV, first bytes: {hdr[:20]}')
|
|
" 2>&1
|
|
else
|
|
echo "No output file created"
|
|
fi
|