- Dahua VTO (e.g. VTO4202F-P)
- Contactron, for example from this link
Prepare various greeting and thank you messages in the style of Star Wars.
Use the service elevenlabs.io/speech-synthesis to convert the prepared texts into MP3 audio files. Save them in the directories ha-sound/gate
(for greetings) and ha-sound/mail
(for thanks).
Perform the MP3 files conversion to the AL format using ffmpeg:
for input in *.mp3; do if [ $(stat -f%z "$input") -lt 102400 ]; then /opt/homebrew/bin/ffmpeg -i "$input" -c:a pcm_alaw -ac 1 -ar 8000 -sample_fmt s16 "${input%.*}.al"; fi; done
Add appropriate prefixes to the file names depending on the directory:
In the gate
directory:
for file in *.al; do mv "$file" "welcome-$file"; done
In the mail
directory:
for file in *.al; do mv "$file" "thankyou-$file"; done
Send the files to HA:
For files in the gate
directory:
scp ha-sound/gate/welcome_*.al root@your-ha:/config/mp3/
For files in the mail
directory:
scp ha-sound/mail/thankyou_*.al root@your-ha0:/config/mp3/
Invocation in HA:
shell_command:
play_thankyou_for_mail: >-
/bin/bash -c "file=$(find /config/mp3 -name 'thankyou-*.al' | shuf -n 1); echo $file; /usr/bin/curl -vvv -F "file=@$file;type=Audio/G.711A" -H "Content-Type: Audio/G.711A" "http://u:[email protected]/cgi-bin/audio.cgi?action=postAudio&httptype=singlepart&channel=1" --speed-limit 1 --speed-time 1;"
play_welcome: >-
/bin/bash -c "file=$(find /config/mp3 -name 'welcome-*.al' | shuf -n 1); echo $file; /usr/bin/curl -vvv -F "file=@$file;type=Audio/G.711A" -H "Content-Type: Audio/G.711A" "http://u:[email protected]/cgi-bin/audio.cgi?action=postAudio&httptype=singlepart&channel=1" --speed-limit 1 --speed-time 1;"
Add automation to your ha as usual and call script. Check scripts and automation in example folder. When someone presses the doorbell, I trigger this script through automation, which interrupts the ringing and plays the greeting.
- Remember to adjust the paths in the above commands to your specific directory structure.