Skip to content

Instantly share code, notes, and snippets.

@BrettSheleski

BrettSheleski/tts.sh Secret

Last active Jan 3, 2019
Embed
What would you like to do?
Script to convert text to speech using naturalreaders.com
#!/bin/bash
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
LC_COLLATE=$old_lc_collate
}
TXT=$(cat)
JSON=$(echo "t=$TXT" | jo)
TXTENCODED=$(urlencode "$TXT")
curl -s "https://kfiuqykx63.execute-api.us-east-1.amazonaws.com/Dev/tts?r=12&s=0&l=0&v=aca&t=${TXTENCODED}" \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0' \
-H 'Accept: */*' \
-H 'Accept-Language: en-US,en;q=0.5' \
--compressed \
-H 'Referer: https://www.naturalreaders.com/online/' \
-H 'content-type: application/x-www-form-urlencoded' \
-H 'origin: https://www.naturalreaders.com' \
-H 'Connection: keep-alive' \
--data "$JSON" \
--output -
@BrettSheleski

This comment has been minimized.

Copy link
Owner Author

@BrettSheleski BrettSheleski commented Jan 3, 2019

Example usage:

echo The cow says moo | ./tts.sh > moo.mp3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment