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

# 発音辞書の使用

> **Note**
>
> **ハウツーガイド** · [ElevenAPI クイックスタート](/docs/ja/eleven-api/quickstart) を完了していることを前提としています。

## 概要

発音辞書を使用すると、AIエージェントが特定の単語やフレーズを発音する方法をカスタマイズできます。特に、次のような場合に便利です。

* 名前、地名、技術用語の発音を修正する
* 会話全体で一貫した発音を維持する
* 地域ごとの発音の違いをカスタマイズする

ElevenLabsは、[IPA](https://en.wikipedia.org/wiki/International_Phonetic_Alphabet) と [CMU](https://en.wikipedia.org/wiki/CMU_Pronouncing_Dictionary) の両方のアルファベットに対応しています。

> **Info**
>
> 発音辞書の音素タグは、eleven_v4、eleven_flash_v2、eleven_v3モデルでのみ機能します。
>
> 他のモデルでは辞書の音素タグがスキップされ、デフォルトの発音が使用されます。必要な発音になるスペルやフレーズに置き換えるには、他のモデルでは代わりに
> エイリアスタグを使用してください。
>
> 英語以外の言語でIPAおよびCMUの発音を使用する場合は、
> eleven_v4モデルに切り替える必要があります。

## クイックスタート

> **Note**
>
> このガイドは、[APIキーとSDKの設定](/docs/ja/eleven-api/quickstart) が完了していることを前提としています。未完了の場合は、先に
> クイックスタートを完了してください。

#### 発音辞書ファイルを作成する

この例では、単語 `tomato` 用の発音辞書ファイルを作成します。

このルールでは「IPA」アルファベットを使用し、`tomato` と `Tomato` の発音を別の発音に更新します。PLSファイルでは大文字と小文字が区別されるため、大文字の「T」の有無それぞれを含めています。

> **Tip**
>
> ClaudeやChatGPTなどのAIツールを使用すると、特定の単語のIPAまたはCMU表記を生成できます。

**`dictionary.pls`**

```xml title="dictionary.pls"
<?xml version="1.0" encoding="UTF-8"?>
<lexicon version="1.0"
    xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon
        http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd"
    alphabet="ipa" xml:lang="en-US">
<lexeme>
    <grapheme>tomato</grapheme>
    <phoneme>/tə'meɪtoʊ/</phoneme>
</lexeme>
<lexeme>
    <grapheme>Tomato</grapheme>
    <phoneme>/tə'meɪtoʊ/</phoneme>
</lexeme>
</lexicon>
```

#### SDKを使用してファイルから発音辞書を作成する

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

```python maxLines=0
from elevenlabs import ElevenLabs, PronunciationDictionaryVersionLocator
from elevenlabs.play import play

elevenlabs = ElevenLabs()

with open("dictionary.pls", "rb") as f:
    # this dictionary changes how tomato is pronounced
    pronunciation_dictionary = elevenlabs.pronunciation_dictionaries.create_from_file(
        file=f.read(), name="example"
    )

audio_1 = elevenlabs.text_to_speech.convert(
    text="Without the dictionary: tomato",
    voice_id="aMSt68OGf4xUZAnLpTU8",
    model_id="eleven_flash_v2",
)

audio_2 = elevenlabs.text_to_speech.convert(
    text="With the dictionary: tomato",
    voice_id="aMSt68OGf4xUZAnLpTU8",
    model_id="eleven_flash_v2",
    pronunciation_dictionary_locators=[
        PronunciationDictionaryVersionLocator(
            pronunciation_dictionary_id=pronunciation_dictionary.id,
            version_id=pronunciation_dictionary.version_id,
        )
    ],
)

# play the audio
play(audio_1)
play(audio_2)
```

```typescript maxLines=0
import { ElevenLabsClient, play } from "@elevenlabs/elevenlabs-js";
import "dotenv/config";
import fs from "node:fs";

const elevenlabs = new ElevenLabsClient();

const pronunciationDictionary = await elevenlabs.pronunciationDictionaries.createFromFile({
    file: fs.createReadStream("dictionary.pls"),
});

const audio1 = await elevenlabs.textToSpeech.convert("Without the dictionary: tomato", {
    voiceId: "aMSt68OGf4xUZAnLpTU8",
    modelId: "eleven_flash_v2",
});

const audio2 = await elevenlabs.textToSpeech.convert("With the dictionary: tomato", {
    voiceId: "aMSt68OGf4xUZAnLpTU8",
    modelId: "eleven_flash_v2",
    pronunciationDictionaryLocators: [
        {
            pronunciationDictionaryId: pronunciationDictionary.id,
            versionId: pronunciationDictionary.versionId,
        },
    ],
});

play(audio1);
play(audio2);
```

#### コードを実行する

```python
python example.py
```

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

スピーカーから、発音辞書ありとなしの2つのバージョンのオーディオが再生されます。

## 次のステップ

#### [APIリファレンス](/docs/ja/api-reference/pronunciation-dictionaries/create-from-file)

発音辞書APIの完全なリファレンスです。

#### [TTSストリーミング](/docs/ja/eleven-api/guides/how-to/text-to-speech/streaming)

より低レイテンシーで再生するために、テキスト読み上げを段階的にストリーミングします。