Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Speech API credentials

I am trying to do some test using the Google Speech API but from outside Google Cloud. In the older beta version I was able to specify a credentials file but now I am unable to find this option in the SpeechClient class.

How can I go about specifying the authentication keys using the Google Speech API Java library?

like image 826
Zaid Amir Avatar asked Dec 19 '22 06:12

Zaid Amir


1 Answers

Some of the classes from Frank's answer are now deprecated. This is an update to his answer.

CredentialsProvider credentialsProvider = FixedCredentialsProvider.create(ServiceAccountCredentials.fromStream(new FileInputStream("path/to/service-account.json")));

SpeechSettings settings = SpeechSettings.newBuilder().setCredentialsProvider(credentialsProvider).build();
SpeechClient speechClient = SpeechClient.create(settings);
like image 85
zjevander Avatar answered Jan 09 '23 13:01

zjevander