> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# Guía de inicio rápido de Diseño de Voz

Esta guía te mostrará cómo diseñar una voz mediante un prompt con la API de Diseño de Voz.

## Uso de la API de Diseño de Voz

> **Note**
>
> Esta guía presupone que ya has [configurado tu clave de API y SDK](/docs/es/eleven-api/quickstart). Completa
> primero la guía de inicio rápido si aún no lo has hecho. Para reproducir audio por los altavoces, puede que también necesites
> [MPV](https://mpv.io/) o [ffmpeg](https://ffmpeg.org/).

#### Haz la solicitud a la API

Diseñar una voz mediante un prompt tiene dos pasos:

1. Genera vistas previas a partir de un prompt.
2. Selecciona la mejor vista previa y úsala para crear una voz nueva.

Empezaremos generando vistas previas a partir de un prompt.

Crea un archivo llamado `example.py` o `example.mts`, según el lenguaje que prefieras, y añade el siguiente código:

```python maxLines=0
# example.py
from dotenv import load_dotenv
from elevenlabs.client import ElevenLabs
from elevenlabs.play import play
import base64

load_dotenv()

elevenlabs = ElevenLabs(
  api_key=os.getenv("ELEVENLABS_API_KEY"),
)

voices = elevenlabs.text_to_voice.design(
    model_id="eleven_multilingual_ttv_v2",
    voice_description="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 preview in voices.previews:
    # Convert base64 to audio buffer
    audio_buffer = base64.b64decode(preview.audio_base_64)

    print(f"Playing preview: {preview.generated_voice_id}")

    play(audio_buffer)
```

```typescript maxLines=0
// 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);
}
```

#### Ejecuta el código

```python
python example.py
```

```typescript
npx tsx example.mts
```

Deberías oír las vistas previas de voz generadas por los altavoces, una a una.

#### Añade la voz generada a tu biblioteca

Cuando hayas generado las vistas previas y elegido tu favorita, puedes añadirla a tu biblioteca de voces mediante el ID de voz generado para usarla con otras API.

```python
voice = elevenlabs.text_to_voice.create(
    voice_name="Jolly giant",
    voice_description="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
    generated_voice_id=voices.previews[0].generated_voice_id
)

print(voice.voice_id)
```

```typescript
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);
```

## Siguientes pasos

#### [Clonación de voz instantánea](/docs/es/eleven-api/guides/how-to/voices/instant-voice-cloning)

Clona una voz a partir de audio existente en lugar de generarla desde una descripción.

#### [Referencia de la API](/docs/es/api-reference/text-to-voice/design)

Referencia y parámetros completos de la API de Diseño de Voz.