how to set credentials for speechClient Java google api 1

how to set credentials for speechClient Java google api

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);

Here is what the above code is Doing:
1. It’s creating a credentials provider using the service account credentials.
2. It’s creating a SpeechSettings object using the credentials provider.
3. It’s creating a SpeechClient object using the SpeechSettings object.

Similar Posts