From bedfdedc60a483de2749c5b403fb563b21378098 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 22 May 2026 16:55:53 +0300 Subject: [PATCH] Simplify ElevenLabs payload and set Rachel as default voice --- backend/.env.example | 2 +- backend/app/Services/GeminiService.php | 7 +------ backend/public/test_elevenlabs.php | 22 ++++++++++++++++------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/backend/.env.example b/backend/.env.example index fb586db..065294b 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -14,7 +14,7 @@ DB_PASSWORD= # AI Model Configuration GEMINI_API_KEY= ELEVENLABS_API_KEY= -ELEVENLABS_VOICE_ID= +ELEVENLABS_VOICE_ID=EXAVITQu4vr4xnSDxMaL # Messaging Gateway Settings WHATSAPP_GATEWAY_URL=http://localhost:3722 diff --git a/backend/app/Services/GeminiService.php b/backend/app/Services/GeminiService.php index fad4280..8920db5 100644 --- a/backend/app/Services/GeminiService.php +++ b/backend/app/Services/GeminiService.php @@ -221,12 +221,7 @@ class GeminiService $url = 'https://api.elevenlabs.io/v1/text-to-speech/' . $voiceId; $payload = json_encode([ - 'text' => $text, - 'model_id' => 'eleven_multilingual_v2', - 'voice_settings' => [ - 'stability' => 0.5, - 'similarity_boost' => 0.8 - ] + 'text' => $text ]); $ch = curl_init($url); diff --git a/backend/public/test_elevenlabs.php b/backend/public/test_elevenlabs.php index cef0515..30b88c1 100644 --- a/backend/public/test_elevenlabs.php +++ b/backend/public/test_elevenlabs.php @@ -57,16 +57,26 @@ echo "\n--- Generating Speech with ElevenLabs ---\n"; $testText = "مرحباً بك! أنا مساعدك الذكي من نبيه، كيف يمكنني مساعدتك اليوم؟"; echo "Text to generate: \"{$testText}\"\n"; +// Test general authentication by querying ElevenLabs models list +echo "\n--- Testing ElevenLabs General Authentication (/v1/models) ---\n"; +$modelsUrl = 'https://api.elevenlabs.io/v1/models'; +$chModels = curl_init($modelsUrl); +curl_setopt($chModels, CURLOPT_RETURNTRANSFER, true); +curl_setopt($chModels, CURLOPT_HTTPHEADER, [ + 'xi-api-key: ' . $elApiKey +]); +$modelsResponse = curl_exec($chModels); +$modelsHttpCode = curl_getinfo($chModels, CURLINFO_HTTP_CODE); +curl_close($chModels); + +echo "Models API HTTP Status Code: {$modelsHttpCode}\n"; +echo "Models API Response: " . substr($modelsResponse, 0, 300) . "\n\n"; + // Execute ElevenLabs TTS directly in this test script to get detailed error logs $url = 'https://api.elevenlabs.io/v1/text-to-speech/' . $elVoiceId; $payload = json_encode([ - 'text' => $testText, - 'model_id' => 'eleven_multilingual_v2', - 'voice_settings' => [ - 'stability' => 0.5, - 'similarity_boost' => 0.8 - ] + 'text' => $testText ]); echo "Sending API request to: {$url}...\n";