summarylogtreecommitdiffstats
path: root/piper-dispatcher
blob: 3cb725693f29772aecc483eaa6d8d313f94e9aca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash

# https://aur.archlinux.org/packages/piper-tts-bin#comment-939482

VOICES_PATH="/usr/share/piper-voices"

if [[ ${VOICE: -3} = low ]]; then
 RATE=16000
else
 RATE=22050
fi

if which pw-play >/dev/null; then
 PLAY_APPS="pw-play --rate $RATE --channel-map LE -"
else
 PLAY_APPS="aplay -r $RATE -f S16_LE -t raw -"
fi

printf %s "$DATA" | piper-tts --model "$VOICES_PATH/$VOICE.onnx" -f - | $PLAY_APPS

wait