0

I am new to use the google API's. I am trying to use the google speech recognition, to convert my speech to text and vise versa. But don't know how to use the google speech API. I download the google cloud package using this command

composer require google/cloud

But I dont know how to use this. I am following tutorial https://github.com/GoogleCloudPlatform/google-cloud-php from this link. but it showing me errors.

Fatal error:  Uncaught Google\Cloud\Exception\ServiceException: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information in /var/www/html/googlevoice/vendor/google/cloud/src/RequestWrapper.php:221
Stack trace:

#0 /var/www/html/googlevoice/vendor/google/cloud/src/RequestWrapper.php(185): Google\Cloud\RequestWrapper->convertToGoogleException(Object(DomainException))
#1 /var/www/html/googlevoice/vendor/google/cloud/src/RequestWrapper.php(167): Google\Cloud\RequestWrapper->fetchCredentials()
#2 /var/www/html/googlevoice/vendor/google/cloud/src/RequestWrapper.php(150): Google\Cloud\RequestWrapper->getToken()
#3 /var/www/html/googlevoice/vendor/google/cloud/src/RequestWrapper.php(131): Google\Cloud\RequestWrapper->signRequest(Object(GuzzleHttp\Psr7\Request))
#4 /var/www/html/googlevoice/vendor/google/cloud/src/RestTrait.php(78): Google\Cloud\RequestWrapper->send(Object(GuzzleHttp\Psr7\Request), Array)
#5 /var/www/html/googlevoice/vendor/goo in /var/www/html/googlevoice/vendor/google/cloud/src/RequestWrapper.php on line 221
Al Foиce ѫ
  • 4,195
  • 12
  • 39
  • 49

1 Answers1

0

First things first it looks like you need to generate your service account credentials :).

Please take a look at this guide in order to get that set up: https://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/guides/authentication

From there you'll want to do the following:

require 'vendor/autoload.php';

use Google\Cloud\Storage\StorageClient;

// Pass the key file directly into your client.
$storage = new StorageClient([
    'keyFilePath' => '/path/to/service/credentials.json'
]);

// OR

// Store the key file as an environment variable
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/credentials.json');

$storage = new StorageClient();
david s
  • 289
  • 1
  • 4
  • Thanks David S for replying – Satvinder Jeet Dec 19 '16 at 13:03
  • I enables all the api thats given on the link provided bu you. but after that i am getting error Fatal error: Uncaught Google\Cloud\Exception\ServiceException: { "error": "deleted_client", "error_description": "The OAuth client was deleted." } in /var/www/html/googlevoice/vendor/google/cloud/src/RequestWrapper.php:219 – Satvinder Jeet Dec 19 '16 at 15:07
  • Interesting! I would recommend regenerating your service account credentials if you haven't tried that yet. If that doesn't work, I would reach out to the support team directly - https://cloud.google.com/support/ – david s Dec 19 '16 at 15:26