> 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.

# ボイスデザイン クイックスタート

このガイドでは、Voice Design APIを使ってプロンプトから音声をデザインする方法を紹介します。

## Voice Design APIの使用

> **Note**
>
> このガイドでは、[APIキーとSDKの設定](/docs/ja/eleven-api/quickstart)が完了していることを前提としています。まだの場合は、まず
> クイックスタートを完了してください。スピーカーからオーディオを再生するには、
> [MPV](https://mpv.io/)や[ffmpeg](https://ffmpeg.org/)も必要になる場合があります。

#### APIリクエストを作成

プロンプトによる音声デザインは、次の2ステップで行います。

1. プロンプトに基づいてプレビューを生成します。
2. 最適なプレビューを選び、新しい音声の作成に使用します。

まず、プロンプトに基づいてプレビューを生成します。

使用する言語に応じて、`example.py`または`example.mts`という新しいファイルを作成し、次のコードを追加します。

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

#### コードを実行

```python
python example.py
```

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

生成された音声プレビューが、1つずつスピーカーから再生されます。

#### 生成した音声をライブラリに追加

プレビューを生成してお気に入りを選んだら、生成された音声IDを使ってボイスライブラリに追加できます。これにより、他の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);
```

## 次のステップ

#### [インスタントボイスクローン](/docs/ja/eleven-api/guides/how-to/voices/instant-voice-cloning)

説明から生成する代わりに、既存のオーディオから音声をクローンします。

#### [APIリファレンス](/docs/ja/api-reference/text-to-voice/design)

Voice Design APIの完全なリファレンスとパラメータ。