Created
August 11, 2018 17:54
-
-
Save dennisstritzke/7c05bfe03d5887ec0964633f042843b0 to your computer and use it in GitHub Desktop.
Retrieve Google Text to Speech entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
APITOKEN=YOUR_TOKEN | |
OUTDIR=voices | |
VOICES=(de-DE-Standard-A de-DE-Standard-B de-DE-Wavenet-A de-DE-Wavenet-B de-DE-Wavenet-C de-DE-Wavenet-D) | |
TEXT="Hier ein deutscher Satz" | |
mkdir -p $OUTDIR | |
for voice in "${VOICES[@]}" | |
do | |
echo -n "Retrieving $voice" | |
curl -sX POST \ | |
"https://texttospeech.googleapis.com/v1beta1/text:synthesize?key=$APITOKEN" \ | |
-H 'Content-Type: application/json' \ | |
-d "{ | |
\"input\": {\"text\": \"$TEXT\"}, | |
\"voice\": {\"languageCode\": \"de-DE\", \"name\":\"$voice\"}, | |
\"audioConfig\": {\"audioEncoding\": \"MP3\"} | |
}" | jq .audioContent | tr -d '"' | base64 -D > $OUTDIR/$voice.mp3 | |
echo " Done" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment