I am using the following code to see if i can use the text to speech api. I am getting a consistent 401 authorization error. I plan to use google cloud text to speech in my existing web app, which was originally using web speech api. I am unable to get the google api to work. Please assist. Thanks. Here is the code I am using:
You are experiencing a problem with the authentication of your Google Cloud API key, according to the 401 authorization error that you are receiving. You might attempt the following solutions to troubleshoot this problem:
Verify in your Google Cloud Console by navigating to the “APIs & Services” section and then selecting “Credentials”.
Verify your Google Cloud Console to make sure the Text-to-Speech API is enabled.
Verify that the API key value in the Authorization header is formatted correctly.
Verify if it fixes the problem, you can also try to generate a new API key and use that in your code.