Skip to content

Instantly share code, notes, and snippets.

@dennisstritzke
Created August 11, 2018 17:54
Show Gist options
  • Save dennisstritzke/7c05bfe03d5887ec0964633f042843b0 to your computer and use it in GitHub Desktop.
Save dennisstritzke/7c05bfe03d5887ec0964633f042843b0 to your computer and use it in GitHub Desktop.
Retrieve Google Text to Speech entries
#!/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