Created
April 29, 2020 10:47
-
-
Save miczed/37636bc5daf3efb68189ba8217a86a76 to your computer and use it in GitHub Desktop.
Synthesize text to speech using google's cloud api and store it as MP3 file.
This file contains 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
printf -e "This will use the google text to speech API to synthesize the text and save it in a file" | |
echo -e "What text should be synthesized?" | |
read text | |
echo -e "What file should the text be stored to (without extension)?" | |
read filename | |
export GOOGLE_APPLICATION_CREDENTIALS="google_credentials.json" | |
echo -e "Downloading audio from google cloud" | |
curl -X POST \ | |
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \ | |
-H "Content-Type: application/json; charset=utf-8" \ | |
-d '{"input":{"text":"'"$text"'"},"voice":{"languageCode":"en-gb","name":"en-GB-Wavenet-A","ssmlGender":"FEMALE"},"audioConfig":{"audioEncoding":"MP3"}}' \ | |
https://texttospeech.googleapis.com/v1/text:synthesize \ | |
| jq -r '.audioContent' | base64 --decode > "$filename.mp3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment