В режиме работы модуля через OAuth Облако такой проблемы не наблюдается (там данные передаются CURL-ом как это и рекомендует Yandex)
Стал искать проблему и нашел, в модуле yandex_tts.class.php, mp3-контент синтезированной речи скрипт получает через функцию file_get_contents, что видимо является недостаточно надежным способом. Файл скачивается с серверов Yandex не полностью.
Мое решение, заменить file_get_contents:
Код: Выделить всё
$contents = file_get_contents($base_url . $qs);
Код: Выделить всё
//------------------------- MY PATH -------------------------
for ($i = 0; $i <= 3; $i++) {
if (!$response) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $base_url . $qs);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if ($post !== false) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
curl_setopt($ch, CURLOPT_HEADER, false);
//curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
//curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$response = curl_exec($ch);
if (curl_errno($ch)) {
if ($this->MyDebug) DebMes("Error: " . curl_error($ch));
}
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200) {
$decodedResponse = json_decode($response, true);
if ($this->MyDebug) DebMes("Error code: " . $decodedResponse["error_code"]);
if ($this->MyDebug) DebMes("Error message: " . $decodedResponse["error_message"]);
} else {
if ($response) {
$contents = $response;
} else {
$contents = NULL;
}
}
curl_close($ch);
}
}
//------------------------- MY PATH -------------------------
Прошу sergejey обратить внимание и внести изменение в модуль.