This repository is a simple implementation of google text-to-speech service.
Require enabled API in GCP (https://console.cloud.google.com/apis/api/texttospeech.googleapis.com)
First and only argument is text for speak ;)
You can change behavior of binary by flags:
Option | Default | Description |
---|---|---|
credentials-path | cloud-proxy | Path to credential file from GCP, default GCP cloud proxy auth |
output-path | output.mp3 | Path to output file with mp3 footage |
pl | false | Flag, when would you to use polish language |
Generate file output.mp3
in workdir in English with GCP Cloud Proxy Auth:
google-speak "Welcome! How are you?"
Generate file output.mp3
in workdir in Polish with credentials.json
auth file.
google-speak -pl -credentials-path credentials.json "Witaj! Co słychać?"
Usage of ./google-speak:
-credentials-path string
Path to credential file (JSON) (default "cloud-proxy")
-output-path string
Output path (mp3 ext required) (default "output.mp3")
-pl
Change context to polish language
Simple pre-compiled version:
- Download binary from releases (https://github.com/oxess/google-speak/releases)
- Upload to server filesystem
scp google-speak server1:/usr/local/bin/google-speak
- Make executable
chmod +x /usr/local/bin/google-speak
Or:
- Download repository
git clone https://github.com/oxess/google-speak
- Go to directory
cd google-speak
- Build dependencies
go mod download
- Compile to binary
go build
- Move to local filesystem
mv google-speak /usr/local/bin/google-speak
- Can file execute
chmod +x /usr/local/bin/google-speak
- Enable text-to-speech API in GCP (https://console.cloud.google.com/apis/api/texttospeech.googleapis.com)
- Create new service account (https://console.cloud.google.com/iam-admin/serviceaccounts/create)
- Go to detail view of this service account > Keys
- Push button "Add key" and "Create new key" and choose "JSON"
- Save file on disk
- Done!
Attention!
You should secure your key for production version.
Do not using didn't secure key on production!