Rate this page:

ElevenLabs

ElevenLabs is an AI voice generator and a text-to-speech provider that you can use with Voximplant services. This article explains how to integrate ElevenLabs TTS into Voximplant Avatar.

Implement basic avatar

Copy URL

Refer to the Avatar's quickstart guide to implement basic avatar. This article has answers to the most common questions and provides a ready-to-use example.

Deploy a backend server for ElevenLabs TTS

Copy URL

Here is a diagram that explains how backend server works:

Backend
  1. A customer talks to an avatar
  2. Avatar identifies the intent
  3. JS code in the avatar scenario sends the text to the backend and waits for the URL of the generated audio
  4. Once received, avatar plays the URL audio back to the user

Implement the following code to run the backend:

Node.js backend code

Node.js backend code

This code example serves the following:

  1. Receives the text to be converted to speech
  2. Sends the text to ElevenLabs
  3. Receives the audio streaming
  4. Converts streaming into an mp3 file and stores it locally
  5. Returns the mp3 file URL as the response

You can use any tool to allow public access to the server you create, for testing purposes we recommend ngrok. Once completed, it provides a public URL to access the backend server.

Modify avatar to use with ElevenLabs TTS

Copy URL

In the avatar, create a JS function to connect with the backend. For example:

Avatar scenario

Avatar scenario

After that, you can use your Avatar with a voice from ElevenLabs.