Closed BSarmady closed 1 year ago
@BSarmady it may have been a transient issue with TestToSpeech/V1/Gapic/*
files.
I am able to generate an audio file like this:
<?php
require_once __DIR__ . '/vendor/autoload.php';
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;
$text = "Hi there, my name is google cloud php library.";
$client = new TextToSpeechClient();
$input_text = (new SynthesisInput())
->setText($text);
// names of voices can be retrieved with $client->listVoices()
$voice = (new VoiceSelectionParams())
->setLanguageCode('en-US')
->setSsmlGender(SsmlVoiceGender::FEMALE);
$audioConfig = (new AudioConfig())
->setAudioEncoding(AudioEncoding::MP3);
$response = $client->synthesizeSpeech($input_text, $voice, $audioConfig);
$audioContent = $response->getAudioContent();
file_put_contents('output.mp3', $audioContent);
print('Audio content written to "output.mp3"' . PHP_EOL);
// exec('/usr/bin/play output.mp3');
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Please run down the following list and make sure you've tried the usual "quick fixes":
If you are still having issues, please be sure to include as much information as possible:
Environment details
Steps to reproduce
Code example
Screen Output
Error Message
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!