Skip to content

Instantly share code, notes, and snippets.

@mohemohe
Last active February 21, 2022 06:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohemohe/b86fe7c9637da73c8d9bacdd2c9983ac to your computer and use it in GitHub Desktop.
Save mohemohe/b86fe7c9637da73c8d9bacdd2c9983ac to your computer and use it in GitHub Desktop.
voiceroid_daemon say
#!/bin/bash
BASE_URL=http://172.16.34.56:8080
#=====================================
function _exit() {
exit 1
}
trap '_exit' {1,2,3,15}
if [ -p /dev/stdin ]; then {
message=$(cat -)
} else {
message="$*"
} fi
while read line; do {
if [ "${line}" == "" ]; then {
sleep 0.3
continue
} fi
echo "${line}"
curl -Ls \
"${BASE_URL}/api/speechtext" \
-X POST \
-H "Content-type: application/json" \
-d "{\"Text\": \"${line}\", \"Speaker\": {\"Speed\": 1.1, \"Emphasis\": 1.1}}" \
| aplay - \
&> /dev/null
sleep 0.3
} done <<EOS
${message}
EOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment