> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Eleven Labs

**ElevenLabsTools** 使代理能够使用 [ElevenLabs](https://elevenlabs.io/docs/product/introduction) 执行音频生成任务。

## 先决条件

您需要安装 `elevenlabs` 库并获取一个 API 密钥，该密钥可从 [Eleven Labs](https://elevenlabs.io/) 获取。

```bash theme={null}
pip install elevenlabs
```

设置 `ELEVEN_LABS_API_KEY` 环境变量。

```bash theme={null}
export ELEVEN_LABS_API_KEY=****
```

## 示例

以下代理将使用 Eleven Labs 根据用户提示生成音频。

```python cookbook/tools/eleven_labs_tools.py theme={null}
from agno.agent import Agent
from agno.tools.eleven_labs import ElevenLabsTools

# 使用 ElevenLabs 工具创建代理
agent = Agent(tools=[
    ElevenLabsTools(
        voice_id="JBFqnCBsd6RMkjVDRZzb", model_id="eleven_multilingual_v2", target_directory="audio_generations"
    )
], name="ElevenLabs Agent")

agent.print_response("Generate a audio summary of the big bang theory", markdown=True)
```

## Toolkit 参数

| 参数                 | 类型              | 默认值                      | 描述                                                                                                             |
| ------------------ | --------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------- |
| `api_key`          | `str`           | `None`                   | 用于身份验证的 Eleven Labs API 密钥。                                                                                    |
| `voice_id`         | `str`           | `JBFqnCBsd6RMkjVDRZzb`   | 用于音频生成的语音 ID。                                                                                                  |
| `target_directory` | `Optional[str]` | `None`                   | 用于保存音频文件的目录。                                                                                                   |
| `model_id`         | `str`           | `eleven_multilingual_v2` | 用于音频生成的模型的 ID。                                                                                                 |
| `output_format`    | `str`           | `mp3_44100_64`           | 用于音频生成的输出格式（有关更多信息，请参阅 [文档](https://elevenlabs.io/docs/api-reference/text-to-speech#parameter-output-format)）。 |

## Toolkit 函数

| 函数                      | 描述            |
| ----------------------- | ------------- |
| `text_to_speech`        | 将文本转换为语音。     |
| `generate_sound_effect` | 根据文本提示生成音效音频。 |
| `get_voices`            | 获取可用语音列表。     |

## 开发者资源

* 查看 [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/eleven_labs.py)
* 查看 [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/elevenlabs_tools.py)
