Discussions

Ask a Question
Back to All

Eleven Labs and Talks API

I have saved voice ID using eleven labs API. And when trying to hit talks API request from my code it throws this error
Client error: POST https://api.d-id.com/talks resulted in a 400 Bad Request response:\n{"kind":"TextToSpeechProviderError","description":"Failed to generate 11labs tts: A voice for the voice_id 3Vd2nkuqshKMQ (truncated...)\n",

My code so far


protected function createDIDTalk($client, $chatgptResponse, $voice_id, $userAvatar)
{
    $body = [
        // 'source_url' => asset($userAvatar->image),
        'source_url' => "https://my-site.co/storage/user/2/random.jpg",
        'script' => [
            'type' => 'text',
            'subtitles' => false,
            'provider' => [
                'type' => 'elevenlabs',
                'voice_id' => $voice_id //3Vd2nkuqshKMQjsM7PSo 
            ],
            'input' => "Laravel is a popular PHP framework used for building web applications. It provides a robust set of tools and features for quickly developing and deploying web projects. Some key features of Laravel include its elegant syntax, built-in authentication system, powerful ORM (Object-Relational Mapping) for working with databases, routing capabilities, middleware support, and more. Laravel is known for its simplicity, performance, and scalability, making it a preferred choice for many developers when working on web development projects."
        ],
        'config' => [
            'fluent' => false,
            'pad_audio' => 0.0
        ]
    ]; 
    $response = $client->request('POST', 'https://api.d-id.com/talks', [
        'body' => json_encode($body),
        'headers' => [
            'accept' => 'application/json',
            'content-type' => 'application/json',
            'authorization' => 'Basic '.config('services.d-id.api_key'),
        ],
    ]);
    dd(json_decode($response->getBody()->getContent(), true), $response);
}

Any leads or solutions?