Skip to content

Instantly share code, notes, and snippets.

@javatask
Created February 6, 2021 18:09
Show Gist options
  • Save javatask/3f05dd905bccc7e6e2b54c0ace9be5da to your computer and use it in GitHub Desktop.
Save javatask/3f05dd905bccc7e6e2b54c0ace9be5da to your computer and use it in GitHub Desktop.
Googles TextToSpeech sample
#!/bin/bash
# check https://cloud.google.com/text-to-speech/docs/quickstart-protocol to get token (subtitles-xxx.json) file
export GOOGLE_APPLICATION_CREDENTIALS="/home/alan/proj/google/textToSpeach/subtitles-xxx.json"
# check https://cloud.google.com/sdk/docs/install
# to install gcloud cli
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
https://texttospeech.googleapis.com/v1beta1/text:synthesize > part.json
cat part.json | jq -r '.audioContent' > partaudio.base64
cat partaudio.base64 | base64 -d > audio.wav
# ffmpeg -i "concat:audio1.wav|audio2.wav" -acodec pcm_s16le output.wav
{
"audioConfig": {
"audioEncoding": "LINEAR16",
"pitch": 0,
"speakingRate": 0.9
},
"input": {
"text": "Hello! The purpose of this video is to demonstrate the process of digital signature strengthening. In the theoretical part, we have already said that taking into account the technology of electronic digital signature overlay, without the electronic signature strengthening procedure it is impossible to guarantee about 10 years of legal validity of this signature and it can be declared void in about two years. Collecting all paper signature documents is considered analogous to this procedure, that is, when a person signs a contract with his or her signature - theoretically, you should verify that signature with the signature in the person's passport."
},
"voice": {
"languageCode": "en-US",
"name": "en-US-Wavenet-D"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment