我正在尝试创建一个使用 Google API Text-To-Speech 的 Text To Speech 服务。嘻嘻是我的代码:
// Setup Google Client
require_once '../../plugins/php/google-api-php-client-2.4.1/vendor/autoload.php';
$client = new Google_Client();
$client->setAuthConfig('../../plugins/php/google-api-php-client-2.4.1/credentials.json');
$client->addScope(Google_Service_Texttospeech::CLOUD_PLATFORM);
$service = new Google_Service_Texttospeech($client);
// Setup Request
$input = new Google_Service_Texttospeech_SynthesisInput();
$input->setText('Japan\'s national soccer team won against Colombia!');
$voice = new Google_Service_Texttospeech_VoiceSelectionParams();
$voice->setLanguageCode('en-US');
$audioConfig = new Google_Service_Texttospeech_AudioConfig();
$audioConfig->setAudioEncoding(Google_Service_Texttospeech_AudioEncoding::MP3);
一切正常,除了最后一行给出错误:
致命错误:未捕获的错误:在 /home/******/public_html/services/remotes/post/convert-text-to-speech.php:28 中找不到类 'AudioEncoding' 堆栈跟踪:#0 {main}在第 28 行抛出 /home/******/public_html/services/remotes/post/convert-text-to-speech.php
对此有什么帮助吗?