File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,8 +33,9 @@ require __DIR__ . '/vendor/autoload.php';
3333use Google\Cloud\TextToSpeech\V1\AudioConfig;
3434use Google\Cloud\TextToSpeech\V1\AudioEncoding;
3535use Google\Cloud\TextToSpeech\V1\SynthesisInput;
36- use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
36+ use Google\Cloud\TextToSpeech\V1\Client\ TextToSpeechClient;
3737use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
38+ use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest;
3839
3940$textToSpeechClient = new TextToSpeechClient();
4041
@@ -44,8 +45,12 @@ $voice = new VoiceSelectionParams();
4445$voice->setLanguageCode('en-US');
4546$audioConfig = new AudioConfig();
4647$audioConfig->setAudioEncoding(AudioEncoding::MP3);
48+ $request = (new SynthesizeSpeechRequest())
49+ ->setInput($input)
50+ ->setVoice($voice)
51+ ->setAudioConfig($audioConfig);
4752
48- $resp = $textToSpeechClient->synthesizeSpeech($input, $voice, $audioConfig );
53+ $resp = $textToSpeechClient->synthesizeSpeech($request );
4954file_put_contents('test.mp3', $resp->getAudioContent());
5055```
5156
You can’t perform that action at this time.
0 commit comments