$testText ]); echo "Sending API request to: {$url}...\n"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'xi-api-key: ' . $elApiKey ]); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlError = curl_error($ch); curl_close($ch); echo "HTTP Status Code: {$httpCode}\n"; if ($curlError) { echo "cURL Error: {$curlError}\n"; } if ($httpCode === 200) { echo "✅ [ElevenLabs] Speech generation successful!\n"; echo "ℹ️ [ElevenLabs] Audio size: " . strlen($response) . " bytes\n"; // Save to test file $outputPath = __DIR__ . '/test_elevenlabs_out.mp3'; file_put_contents($outputPath, $response); echo "✅ [ElevenLabs] Audio successfully written to: " . basename($outputPath) . "\n"; } else { echo "❌ [ElevenLabs] Speech generation failed.\n"; echo "Response: " . $response . "\n"; } echo "\n=== Diagnostics Complete ===\n";