- Go to the cloud, select your project
- Go to API & Services > credentials, generate an API key
- Give the API key access to all services
- Enable https://console.cloud.google.com/apis/library/texttospeech.googleapis.com?project=compass-436221&pli=1&inv=1&invt=Ab4Plg
- Use the following request
curl -X POST -H "Content-Type: application/json" \
-H "x-goog-api-key: GOOGLE_API_KEY" \
--data '{
"input": {
"markup": "Buenos dias"
},
"voice": {
"languageCode": "es-ES",
"name": "es-ES-Chirp3-HD-Schedar",
"voiceClone": {}
},
"audioConfig": {
"audioEncoding": "LINEAR16",
"speakingRate": 0.85
}
}' "https://texttospeech.googleapis.com/v1/text:synthesize"
- Convert the output to an audio file:
cat response.json | jq -r '.audioContent' | base64 -D > decoded.wav