Last active
July 8, 2020 13:24
-
-
Save gabriserra/c849eb626a48182b366b8b3c6a628017 to your computer and use it in GitHub Desktop.
Allows to generate an mp3 audio track of specified text. Uses Google Cloud service and need Google Cloud CLI
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
# export Google Credentials service account path | |
export GOOGLE_APPLICATION_CREDENTIALS=~/Keys/da-service-account.json | |
curl \ | |
-vX POST https://texttospeech.googleapis.com/v1/text:synthesize \ | |
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ | |
-H "Content-Type: application/json; charset=utf-8" \ | |
-d @ttsbody.json > synthesize-text.txt # specify your json file | |
# get response and encode as mp3 | |
cat synthesize-text.txt | grep 'audioContent' | \ | |
sed 's|audioContent| |' | tr -d '\n ":{},' > tmp.txt && \ | |
base64 tmp.txt --decode > synthesize-text-audio.mp3 && \ | |
rm synthesize-text.txt \ | |
rm tmp.txt |
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
{ | |
"audioConfig": { | |
"audioEncoding": "mp3", | |
"effectsProfileId": [ | |
"small-bluetooth-speaker-class-device" | |
], | |
"pitch": 0, | |
"speakingRate": 1 | |
}, | |
"input": { | |
"text": "Benvenuto in Delivery Aggregator! Premi \"uno\" per ricevere assistenza tecnica, premi \"due\" per ricevere assistenza commerciale oppure premi \"tre\" per ricevere assistenza amministrativa." | |
}, | |
"voice": { | |
"languageCode": "it-IT", | |
"name": "it-IT-Wavenet-A" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment