<?php


// require __DIR__ . '/vendor/autoload.php';

require_once  'vendor/autoload.php';



// use Google\Auth\ApplicationDefaultCredentials;
// use GuzzleHttp\Client;
// use GuzzleHttp\HandlerStack;
use Google\Cloud\TextToSpeech\V1\AudioConfig;
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;

putenv("GOOGLE_APPLICATION_CREDENTIALS=contentio-360506-ffb3b80c3473.json");

$textToSpeechClient = new TextToSpeechClient();

$input = new SynthesisInput();
// $input->setText('Japan\'s national soccer team won against Colombia!');
$input->setSsml('<speak>
                Japan\'s national soccer team <break time="3s" /> won against Colombia!
            </speak>');
$voice = new VoiceSelectionParams();
$voice->setLanguageCode('en-US');
$audioConfig = new AudioConfig();
$audioConfig->setAudioEncoding(AudioEncoding::MP3);

$resp = $textToSpeechClient->synthesizeSpeech($input, $voice, $audioConfig);
file_put_contents('test1.mp3', $resp->getAudioContent());