ElevenLabs Voice Design: preview and save a voice
Follow the official quickstart to generate voice previews from a description, then save one to your library by generatedVoiceId. No product or API was run.
Task and deliverable · Prepare the input and environment · Mechanism and data flow
At a glance
This tutorial relies only on the official ElevenLabs Voice Design quickstart. It covers generating several preview voices from a written description and saving one of them to the voice library. The two JavaScript snippets from the page appear in the code area exactly as supplied, so the prose explains only their variables, prerequisites and checks. The voice comes from a description and is not a clone of a real person; the official page lists cloning as a separate path that starts from existing audio.
Task workflow
Two stages: generate previews, then create the voice
The official page splits prompt-based design into two steps: generate previews from a prompt, then pick one preview and create a new voice from it. The first step calls
elevenlabs.textToVoice.designwithmodelId(the example useseleven_multilingual_ttv_v2), avoiceDescriptionfor the voice, and thetextthe previews will speak. The returnedpreviewsis a list, and the example readsaudioBase64andgeneratedVoiceIdfrom each item. The second step callselevenlabs.textToVoice.createand hands it the chosen preview'sgeneratedVoiceId. A person has to listen and choose between the two calls.How the snippets relate to the runtime
The first snippet is the full
example.tscontent: it imports the client andplay, creates the client, callsdesign, then loops overpreviews. In the loop,Buffer.from(preview.audioBase64, 'base64')decodes the base64 into a buffer, which is wrapped in aReadablestream, thegeneratedVoiceIdis logged, andawait play(audioStream)plays it, so previews play one after another. The second snippet is a fragment. It useselevenlabsandpreviewsfrom the first one and imports or creates nothing itself, so it cannot run alone. This task uses an interactive session that retains bindings: generate, listen and choose, then execute the save fragment separately without rerunning generation. That execution arrangement is an editorial recommendation. Neither snippet shows that the voice matches your intent; they only show the call syntax.Two ID fields with distinct roles, and a human choice
The preview stage yields a
generatedVoiceId. After saving,createreturnsvoice.voiceId, which is the ID you use to reference the voice in other APIs. The fields have distinct roles:generatedVoiceIdselects a generated preview, whilevoice.voiceIdreferences a created voice. This page does not guarantee unequal string values. The official example picks the first preview withpreviews[0], and its comment says this is only for the example. To choose by ear, listen to all previews first and change the index yourself; the first preview is not an automatic selection. Note also that the example'svoiceNameis "Jolly giant" and itsvoiceDescriptiondescribes a giant, which does not match the ogre description used for the previews, so decide for yourself what to put in those fields.Source facts, editorial advice and what was not run
The source facts here are the two-step API flow, the snippet code, the possible need for MPV and ffmpeg, and the official statement that you should hear the previews played one at a time. Static and semantic checks, handling of errors or a stop partway through, and credential cleanup are editorial recommendations, not official behavior. The official page documents no cancellation API, and this tutorial does not invent one. No code was run in this batch, no product or API was called and no dependency was installed, so the text contains no actual observed results.
Task and deliverable
This tutorial relies only on the official ElevenLabs Voice Design quickstart. It covers generating several preview voices from a written description and saving one of them to the voice library. The two JavaScript snippets from the page appear in the code area exactly as supplied, so the prose explains only their variables, prerequisites and checks. The voice comes from a description and is not a clone of a real person; the official page lists cloning as a separate path that starts from existing audio.
Prepare the input and environment
- Finish the official API quickstart first and set up your API key and SDK. The page assumes this is already done. This tutorial does not cover how to get a key or check account permissions.
- The code uses
@elevenlabs/elevenlabs-jsanddotenv/config, and both must be installed and configured beforehand. The TypeScript code createsElevenLabsClientwithout passing a key, so how the key is read depends on your quickstart setup, which this page does not describe further. - The official standalone preview uses
example.mtsandnpx tsx example.mtswith ESM top-levelawait. For choosing and saving after listening, this task instead uses an interactive JavaScript/TypeScript environment that supports ESM imports and top-levelawaitand retainselevenlabsandpreviewsbetween separate executions. This is an editorial recommendation; confirm binding persistence before starting. Speaker playback may need MPV and/or ffmpeg, according to the source. - The page gives no preview retention period, no per-language quality guarantee, no commercial-use terms and no call cost, and this tutorial does not guess any of them. Check the official documentation before relying on them.
Mechanism and data flow
Two stages: generate previews, then create the voice: The official page splits prompt-based design into two steps: generate previews from a prompt, then pick one preview and create a new voice from it. The first step calls elevenlabs.textToVoice.design with modelId (the example uses eleven_multilingual_ttv_v2), a voiceDescription for the voice, and the text the previews will speak. The returned previews is a list, and the example reads audioBase64 and generatedVoiceId from each item. The second step calls elevenlabs.textToVoice.create and hands it the chosen preview's generatedVoiceId. A person has to listen and choose between the two calls.
How the snippets relate to the runtime: The first snippet is the full example.ts content: it imports the client and play, creates the client, calls design, then loops over previews. In the loop, Buffer.from(preview.audioBase64, 'base64') decodes the base64 into a buffer, which is wrapped in a Readable stream, the generatedVoiceId is logged, and await play(audioStream) plays it, so previews play one after another. The second snippet is a fragment. It uses elevenlabs and previews from the first one and imports or creates nothing itself, so it cannot run alone. This task uses an interactive session that retains bindings: generate, listen and choose, then execute the save fragment separately without rerunning generation. That execution arrangement is an editorial recommendation. Neither snippet shows that the voice matches your intent; they only show the call syntax.
Two ID fields with distinct roles, and a human choice: The preview stage yields a generatedVoiceId. After saving, create returns voice.voiceId, which is the ID you use to reference the voice in other APIs. The fields have distinct roles: generatedVoiceId selects a generated preview, while voice.voiceId references a created voice. This page does not guarantee unequal string values. The official example picks the first preview with previews[0], and its comment says this is only for the example. To choose by ear, listen to all previews first and change the index yourself; the first preview is not an automatic selection. Note also that the example's voiceName is "Jolly giant" and its voiceDescription describes a giant, which does not match the ogre description used for the previews, so decide for yourself what to put in those fields.
Source facts, editorial advice and what was not run: The source facts here are the two-step API flow, the snippet code, the possible need for MPV and ffmpeg, and the official statement that you should hear the previews played one at a time. Static and semantic checks, handling of errors or a stop partway through, and credential cleanup are editorial recommendations, not official behavior. The official page documents no cancellation API, and this tutorial does not invent one. No code was run in this batch, no product or API was called and no dependency was installed, so the text contains no actual observed results.
Workflow map
| Stage | What happens |
|---|---|
| Two stages: generate previews, then create the voice | The official page splits prompt-based design into two steps: generate previews from a prompt, then pick one preview and create a new voice from it. |
| How the snippets relate to the runtime | The first snippet is the full example.ts content: it imports the client and play, creates the client, calls design, then loops over previews. |
| Two ID fields with distinct roles, and a human choice | The preview stage yields a generatedVoiceId. |
| Source facts, editorial advice and what was not run | The source facts here are the two-step API flow, the snippet code, the possible need for MPV and ffmpeg, and the official statement that you should hear the previews played one at a time. |
Complete the task
Confirm the prerequisites: First confirm that you finished the official API quickstart and that your API key and SDK are set up. Then confirm that dotenv/config and @elevenlabs/elevenlabs-js are available and that your runtime can execute top-level await. If you want to hear previews through speakers, check whether MPV or ffmpeg is installed, since the page says you may need one or both. The point of this step is to rule out environment problems before the call, so a missing tool is not mistaken for an API failure.
Prepare separate executions (editorial recommendation): the source gives a standalone preview command using example.mts, but variables do not survive the file process ending. To save the same preview batch you heard, confirm that your interactive environment supports the shown imports and top-level await and keeps variable bindings. Execute the original first fragment as generation and playback; do not append the saving fragment and run both together. The code describes an ogre voice and supplies speech text. If you change them, listen to and judge that newly generated batch.
Generate and listen: execute only the first fragment in the interactive session. It logs each generatedVoiceId and plays previews; the source says you should hear them one at a time. Finish listening to this batch before choosing. On errors, silence or an empty list, record incomplete work and check prerequisites without saving. Keep the same session and original elevenlabs and previews. Editorial recommendation: if the session ends or bindings are lost, this flow cannot continue from the previous listening choice. Do not rerun the generation file to save that choice; a new batch requires a new listen and selection.
Choose a preview by ear and record its ID: After listening to all the previews, decide yourself which one to keep. The official example takes previews[0] only to keep the example simple. If you want a different preview, put its index or generatedVoiceId in its place, and make sure the value comes from this run's results. Editorial recommendation: write down how each generatedVoiceId sounded before you decide, rather than relying on memory, and do not describe the first preview as something the system recommended.
Save the selected preview from the same batch (editorial recommendation): remain in the original interactive session, confirm that the index points to the generatedVoiceId you just chose by listening, then execute the second fragment separately. Do not rerun any file containing design. The official save fragment defaults to previews[0]; for another choice, change the index only in your environment after confirming it. voiceName and voiceDescription are library metadata. The original uses Jolly giant and a giant description, unlike the earlier ogre, so check them for your purpose. After create, the code prints voice.voiceId for the created voice. That field alone does not prove that you saved the preview you chose.
Check the outcome and clean up: Success means you heard and selected a preview from this batch, saved using the retained batch's previews and chosen generatedVoiceId, and received a recordable voiceId from create. Failure means any call throws an error, previews is empty, or you hear nothing. In those cases check the prerequisites and MPV or ffmpeg before deciding whether to retry; the page gives no error codes or retry rules. These success and failure conditions, and what to do when you stop on your own, are editorial recommendations. In every exit path, whether success, failure, empty output or a manual stop, clean up: do not commit .env or the key to a repository or paste it into screenshots or logs, handle the key according to your account practice when you no longer need it, and close any process still running.
Worked example
The official example has two parts. The first asks for a massive ogre who speaks at a quick pace with a silly, resonant tone, and has it read a threatening speech that begins "Your weapons are but toothpicks to me", using the model eleven_multilingual_ttv_v2. The program loops over previews, plays each one and logs its generatedVoiceId. The second part needs an environment retaining the first part's bindings. The editor recommends executing it separately after listening and choosing in the same interactive session, without rerunning generation. The official save sample creates a voice with Jolly giant as voiceName, a description of a giant at least as tall as a building with a deep, booming, jolly voice as voiceDescription, and previews[0].generatedVoiceId, then prints the new voice.voiceId. This is the official documentation's example and not an observation from this batch, which did not run it.
// example.ts
import { ElevenLabsClient, play } from "@elevenlabs/elevenlabs-js";
import "dotenv/config";
import { Readable } from 'node:stream';
import { Buffer } from 'node:buffer';
const elevenlabs = new ElevenLabsClient();
const { previews } = await elevenlabs.textToVoice.design({
modelId: "eleven_multilingual_ttv_v2",
voiceDescription: "A massive evil ogre speaking at a quick pace. He has a silly and resonant tone.",
text: "Your weapons are but toothpicks to me. Surrender now and I may grant you a swift end. I've toppled kingdoms and devoured armies. What hope do you have against me?",
});
for (const preview of previews) {
// Convert base64 to buffer and create a Readable stream
const audioStream = Readable.from(Buffer.from(preview.audioBase64, 'base64'));
console.log(`Playing preview: ${preview.generatedVoiceId}`);
// Play the audio using the stream
await play(audioStream);
}
const voice = await elevenlabs.textToVoice.create({
voiceName: "Jolly giant",
voiceDescription: "A huge giant, at least as tall as a building. A deep booming voice, loud and jolly.",
// The generated voice ID of the preview you want to use,
// using the first in the list for this example
generatedVoiceId: previews[0].generatedVoiceId
});
// The ID of the newly created voice, use this to reference the voice in other APIs
console.log(voice.voiceId);
Check the result and failure paths
- Static check (editorial recommendation): the interactive environment supports the shown imports and top-level
await, retainselevenlabsandpreviewsafter generation, and has not yet executed saving. Confirm the index matches the chosen ID from this listening batch. - Run check (source-reported): after running, you should hear the previews played one at a time, with a
generatedVoiceIdline logged for each. If you hear nothing, check MPV or ffmpeg first, then the key and SDK setup. - Save check (source and editorial recommendation): confirm that
createuses the chosengeneratedVoiceIdretained in the same session, then recordvoice.voiceId. Their roles differ without a guarantee that their string values differ; check subsequent API use separately. - Semantic check (editorial recommendation): whether the sound fits your description is a human judgment that the code cannot prove, and the page promises no language or style result.
- Stopping condition (editorial recommendation): if an error occurs,
previewsis empty, or you decide not to save, skip the save step and clean up credentials and processes as described.
Scope and limits
- This tutorial covers only the TypeScript path and its two snippets from the official Voice Design quickstart. It does not explain the Python code or voice cloning.
- The page does not state how long previews are kept, whether any language is guaranteed, whether a saved voice can be used commercially, or what calls cost, and this tutorial makes no claim about them.
- The second snippet is not a standalone program. It needs the existing
elevenlabsandpreviews, and your runtime must satisfy the top-levelawaitrequirement. - The completion checks and manual stopping steps are editorial recommendations, not official behavior, and the official page provides no cancellation API.
No product or API was run in this batch: no dependency was installed, and no account, key or login was used. Any result described here comes from the official page or from reader expectation, not from observation in this batch.
Article sources
Original editorial content; official descriptions and checking suggestions are distinguished.