[Unit]
Description=Wyoming Satellite
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
ExecStart={{ ansible_env.HOME }}/wyoming-satellite/script/run \
--name '{{ ansible_hostname }}' \
--uri 'tcp://{{ wyoming.listen_ip }}:{{ wyoming.listen_port }}' \
--mic-command 'arecord -r 16000 -c 1 -f S16_LE -t raw {% if hostvars[inventory_hostname].mic_device %}-D {{hostvars[inventory_hostname].mic_device}}{% endif %}' \
--snd-command 'aplay -r 22050 -c 1 -f S16_LE -t raw {% if hostvars[inventory_hostname].speaker_device %}-D {{hostvars[inventory_hostname].speaker_device}}{% endif %}' \
--awake-wav sounds/listening.wav \
--done-wav sounds/finished.wav \
--timer-finished-wav sounds/timer_finished.wav \
--mic-auto-gain {{ wyoming.mic_auto_gain }} \
--mic-noise-suppression {{ wyoming.mic_noise_suppression }} \
--mic-volume-multiplier {{ hostvars[inventory_hostname].mic_volume_multiplier }} \
--wake-uri '{{ wyoming.wake_uri }}' \
--wake-word-name '{{ wyoming.wake_word_name }}' \
--wake-refractory-seconds {{ wyoming.wake_refractory_seconds }} \
--timer-finished-wav-repeat 10 1 \
--debug \
--debug-recording-dir /tmp
WorkingDirectory={{ ansible_env.HOME }}/wyoming-satellite
Restart=always
RestartSec=1

[Install]
WantedBy=default.target