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

# 发音词典

## 概述

发音词典可让你自定义 AI 智能体对特定单词或短语的发音。尤其适用于：

* 纠正姓名、地名或技术术语的发音
* 确保不同对话中的发音保持一致
* 自定义地区发音差异

## 配置

> **Note**
>
> 发音词典的音素标签仅适用于 eleven_v4、eleven_flash_v2 和 eleven_v3 模型。
>
> 其他模型会跳过词典音素标签，并使用默认发音。对于其他模型，请改用别名标签，替换为能产生所需发音的拼写或短语。
>
> 如果想在英语以外的语言中使用 IPA 和 CMU 发音，需切换到 eleven_v3 或 eleven_v4 模型。

### 为智能体添加词典

#### 通过控制台更新

在控制台中打开智能体，前往 **音色设置**，然后添加发音词典。保存更改。

![从智能体音色设置中添加发音词典](/docs/_fern-img/1e7c851096776b9b8cb39cc95b54d394cc02ec7e4771d13958a259accf0ad757.webp)

#### 通过 CLI 更新

#### 拉取智能体配置

```bash
elevenlabs agents pull --agent "<agent-name>"
```

#### 编辑 \`agent_configs/\<agent-name>.json\`

设置 `conversation_config.tts.pronunciation_dictionary_locators`：

```json
{
  "conversation_config": {
    "tts": {
      "pronunciation_dictionary_locators": [
        {
          "pronunciation_dictionary_id": "<dictionary-id>",
          "version_id": "<version-id>"
        }
      ]
    }
  }
}
```

#### 推送更改

```bash
elevenlabs agents push --agent "<agent-name>"
```

#### 通过 API 更新

```python
from elevenlabs import ElevenLabs

elevenlabs = ElevenLabs()

elevenlabs.conversational_ai.agents.update(
    agent_id="agent_7101k5zvyjhmfg983brhmhkd98n6",
    conversation_config={
        "tts": {
            "pronunciation_dictionary_locators": [
                {
                    "pronunciation_dictionary_id": "<dictionary-id>",
                    "version_id": "<version-id>",
                }
            ]
        },
    },
)
```

```typescript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";

const elevenlabs = new ElevenLabsClient();

await elevenlabs.conversationalAi.agents.update("agent_7101k5zvyjhmfg983brhmhkd98n6", {
  conversationConfig: {
    tts: {
      pronunciationDictionaryLocators: [
        {
          pronunciationDictionaryId: "<dictionary-id>",
          versionId: "<version-id>",
        },
      ],
    },
  },
});
```

## 词典文件格式

发音词典使用基于 XML 的 `.pls` 文件。以下是示例结构：

```xml
<?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-GB">
  <lexeme>
    <grapheme>Apple</grapheme>
    <phoneme>ˈæpl̩</phoneme>
  </lexeme>
  <lexeme>
    <grapheme>UN</grapheme>
    <alias>United Nations</alias>
  </lexeme>
</lexicon>
```

## 支持的格式

发音词典支持两种发音标注：

1. **IPA（国际音标）**

   * 更精确地控制发音
   * 需要了解 IPA 符号
   * 示例："nginx" 的发音为 `/ˈɛndʒɪnˈɛks/`

2. **CMU（卡内基梅隆大学）词典格式**
   * 更简单的基于 ASCII 的格式
   * 更易用于英语发音
   * 示例："tomato" 的发音为 "T AH M EY T OW"

> **Tip**
>
> 可使用 Claude 或 ChatGPT 等 AI 工具，为特定单词生成 IPA 或 CMU 标注。

## 最佳实践

1. **大小写敏感**：如有需要，请为单词的大写和小写形式分别创建条目
2. **测试**：务必使用所选音色和模型测试发音
3. **维护**：保持词典有序并记录说明
4. **范围**：重点关注经常被误读或对使用场景至关重要的单词

## 常见问题

#### 哪些模型支持基于音素的发音？

发音词典的音素标签仅适用于 eleven_v4、eleven_flash_v2 和 eleven_v3 模型。

其他模型会跳过词典音素标签，并使用默认发音。对于其他模型，请改用别名标签，替换为能产生所需发音的拼写或短语。

如果想在英语以外的语言中使用 IPA 和 CMU 发音，需切换到 eleven_v4 或 eleven_v3 模型。

#### 可以使用多个词典吗？

可以。你可以上传多个词典文件，以处理不同的发音集合。

#### 如果词典中没有某个单词，会怎样？

对于词典中未指定的单词，模型会使用其默认发音规则。

## 更多资源

* [专业语音克隆](/docs/zh/eleven-creative/voices/voice-cloning/professional-voice-cloning)
* [声音设计](/docs/zh/eleven-creative/voices/voice-design)
* [文本转语音 API 参考文档](/docs/zh/api-reference/text-to-speech/convert)