I’ve made a shell script that can do this on the AD410 Amcrest that I can call from HA. Works okay.
#!/bin/bash
TEXT="$1"
LOG=ttslog
LOG=/config/ttslog
echo "TEXT: $TEXT" > $LOG
FILE=`curl -v -X POST \
-H "Authorization: Bearer xxxxxxx" \
-H "Content-Type: application/json" \
-d "{\"message\": \"$TEXT\", \"platform\": \"google_cloud\"}" \
https://ha.xxxx.xxxx:18123/api/tts_get_url | awk -F/ '{print $6}' |awk -F\" '{print $1}'` >> $LOG 2>&1
echo CURLRC=$? >> $LOG
echo
echo FILE:$FILE >> $LOG
echo
ffmpeg -y -i "/config/tts/$FILE" -c:a pcm_alaw -ac 1 -ar 8000 -sample_fmt s16 /config/audio_test.al >> $LOG 2>&1
echo FFMPEGRC=$? >> $LOG
echo
# --digest
curl -vvv --user 'admin:xxxxxxV' \
--limit-rate 8K \
--expect100-timeout 3 \
--connect-timeout 5 \
--no-keepalive \
--max-time 7 \
-F "[email protected]/config/audio_test.al;type=Audio/G.711A" \
-H "Content-Type: Audio/G.711A" \
-H "content-length: 9999999" \
"http://10.100.1.143/cgi-bin/audio.cgi?action=postAudio&httptype=singlepart&channel=1" >> $LOG 2>&1
echo DOORRC=$? >> $LOG
exit 0
shell_command:
doorbelltts: >-
/config/ttsplay "{{ states('input_text.tts_door_text') }}"
It would be easier if the gstreamer integration was available in HA.