This post is my memo about how Cloud Text-to-Speech API from Google uses
Create your project
First of all, you visit Google Cloud Platform and create and create a project.
You select the library from API and Service beside home menu at the right side. Then turn on the following APIs
- Cloud Text-to-Speech API
- Cloud Speech API
As the Cloud Text-to-Speech API consists of charging system, you are required to register your credit card. You can choose free trial for free in 12 months. If you should overuse beyond free points, you never charge the extra cost under secret. So you can feel free to use. In case of surpass, Google notify some of information to you in advance.
The Cloud Text-to-Speech allow to use not more than 60 minutes(request) a month for free charging. Over the time, you will be charged for $0.006 per 15 seconds.
So that you control voice audio in node.js you install sox library.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null brew install sox
Before starting, prepare a folder where you want and download sample code from Google. I customized it with following code.
Support Language is here
Create Service Account
You visit GCP Console and go to [API Manager] → [Credentials]. After the procedure [setup an API key] → [setup a service account], json file will be generated. Just put it in your directory.
Link GOOGLE_APPLICATION_CREDENTIALS variable into path. Go to your directory where you put the json file and type following command in terminal.
Once I run the code, I got confusion because none of reactions was in my console. After few seconds the results analyzed strings from voices came out. Although I got the outcome, it was not yet somewhat realtime. Searching precise settings in the sample code, I found it.
All you have to do is set
interimResults true . You can see the progress in realtime.