I am running the php code provided on the documentation page of text-to-api page. After running every 8-10 times successfuly. It gives me
Error creating resource: [message] fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known [file] /Desktop/php_projects/text_speech/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php [line] 323 [message] fopen(https://oauth2.googleapis.com/token): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known [file] /Desktop/php_projects/text_speech/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php [line] 323
It gives me error where on this line
$response = $client->synthesizeSpeech($synthesisInputText, $voice, $audioConfig);
require __DIR__ . '/vendor/autoload.php';
// Imports the Cloud Client Library
use Google\Cloud\TextToSpeech\V1\AudioConfig;
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender;
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
$client = new TextToSpeechClient([
'credentials' => ('/Documents/gcp_credentials/config.json')
]);
$synthesisInputText = (new SynthesisInput())
->setText('Hello, world! This is just for testing purpose.Lorem Ipsum is simply dummy text of the printing and typesetting industry.This is just for testing purpose.Lorem Ipsum is simply dummy text of the printing and typesetting industry');
$voice = (new VoiceSelectionParams())
->setLanguageCode('en-IN')
->setName('en-IN-Wavenet-A')
->setSsmlGender(SsmlVoiceGender::FEMALE);
$effectsProfileId = "telephony-class-application";
$audioConfig = (new AudioConfig())
->setAudioEncoding(AudioEncoding::LINEAR16)
->setEffectsProfileId(array($effectsProfileId));
$response = $client->synthesizeSpeech($synthesisInputText, $voice, $audioConfig);
$audioContent = $response->getAudioContent();
file_put_contents('output.wav', $audioContent);
I want to output the result error free every time I run this code.