API has not been used in project 563584335869 before or it is disabled
1 min readSep 25, 2020
Original error message
Error: 7 PERMISSION_DENIED: Cloud Text-to-Speech API has not been used in project 563584335869 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/texttospeech.googleapis.com/overview?project=563584335869 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
The project id 563584335869 is not yours. It is firebase-cli cloud project’s project-id. So, the problem is because you have to set the configuration by yours, but you didn’t.
Solution
const textToSpeech = require("@google-cloud/text-to-speech")
const keyfile = require(".././my-project.json")const config = {
projectId: keyfile.project_id,
keyFilename: require.resolve(".././my-project.json")
};const TTS_Client = new textToSpeech.TextToSpeechClient(config)
Now, you can be passed with your configuration.
LINK:
https://github.com/googleapis/nodejs-text-to-speech/issues/26#issuecomment-397528174
“my-project.json” is a file of your credential what allow you can access to google API.
And you have to make your credential and download that in your cloud console before.