Simplify ElevenLabs payload and set Rachel as default voice

This commit is contained in:
Hamza-Ayed
2026-05-22 16:55:53 +03:00
parent ae1f66ae6e
commit bedfdedc60
3 changed files with 18 additions and 13 deletions

View File

@@ -14,7 +14,7 @@ DB_PASSWORD=
# AI Model Configuration # AI Model Configuration
GEMINI_API_KEY= GEMINI_API_KEY=
ELEVENLABS_API_KEY= ELEVENLABS_API_KEY=
ELEVENLABS_VOICE_ID= ELEVENLABS_VOICE_ID=EXAVITQu4vr4xnSDxMaL
# Messaging Gateway Settings # Messaging Gateway Settings
WHATSAPP_GATEWAY_URL=http://localhost:3722 WHATSAPP_GATEWAY_URL=http://localhost:3722

View File

@@ -221,12 +221,7 @@ class GeminiService
$url = 'https://api.elevenlabs.io/v1/text-to-speech/' . $voiceId; $url = 'https://api.elevenlabs.io/v1/text-to-speech/' . $voiceId;
$payload = json_encode([ $payload = json_encode([
'text' => $text, 'text' => $text
'model_id' => 'eleven_multilingual_v2',
'voice_settings' => [
'stability' => 0.5,
'similarity_boost' => 0.8
]
]); ]);
$ch = curl_init($url); $ch = curl_init($url);

View File

@@ -57,16 +57,26 @@ echo "\n--- Generating Speech with ElevenLabs ---\n";
$testText = "مرحباً بك! أنا مساعدك الذكي من نبيه، كيف يمكنني مساعدتك اليوم؟"; $testText = "مرحباً بك! أنا مساعدك الذكي من نبيه، كيف يمكنني مساعدتك اليوم؟";
echo "Text to generate: \"{$testText}\"\n"; 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 // Execute ElevenLabs TTS directly in this test script to get detailed error logs
$url = 'https://api.elevenlabs.io/v1/text-to-speech/' . $elVoiceId; $url = 'https://api.elevenlabs.io/v1/text-to-speech/' . $elVoiceId;
$payload = json_encode([ $payload = json_encode([
'text' => $testText, 'text' => $testText
'model_id' => 'eleven_multilingual_v2',
'voice_settings' => [
'stability' => 0.5,
'similarity_boost' => 0.8
]
]); ]);
echo "Sending API request to: {$url}...\n"; echo "Sending API request to: {$url}...\n";