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

# 即时语音克隆快速入门

本指南将介绍如何使用克隆声音 API 创建即时语音克隆。要通过控制台创建即时语音克隆，请参阅[即时语音克隆](/docs/zh/eleven-creative/voices/voice-cloning/instant-voice-cloning)产品指南。

如需深入了解 IVC 和 PVC 的工作原理及其适用场景，请参阅[语音克隆：工作原理](/docs/zh/eleven-api/concepts/voice-cloning)。

## 使用即时语音克隆 API

> **Note**
>
> 本指南假定你已[设置 API 密钥和 SDK](/docs/zh/eleven-api/quickstart)。如果尚未设置，请先完成
> 快速入门。

#### 发起 API 请求

根据所选语言，新建名为 `example.py` 或 `example.mts` 的文件，然后添加以下代码：

```python maxLines=0
# example.py
import os
from dotenv import load_dotenv
from elevenlabs.client import ElevenLabs
from io import BytesIO

load_dotenv()

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

voice = elevenlabs.voices.ivc.create(
    name="My Voice Clone",
    # Replace with the paths to your audio files.
    # The more files you add, the better the clone will be.
    files=[BytesIO(open("/path/to/your/audio/file.mp3", "rb").read())]
)

print(voice.voice_id)
```

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

const elevenlabs = new ElevenLabsClient();

const voice = await elevenlabs.voices.ivc.create({
    name: "My Voice Clone",
    // Replace with the paths to your audio files.
    // The more files you add, the better the clone will be.
    files: [
        fs.createReadStream(
            "/path/to/your/audio/file.mp3",
        ),
    ],
});

console.log(voice.voiceId);
```

#### 执行代码

```python
python example.py
```

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

控制台中会显示音色 ID。

## 后续步骤

#### [专业语音克隆](/docs/zh/eleven-api/guides/how-to/voices/professional-voice-cloning)

在语音样本上微调模型，创建质量更高的克隆声音。

#### [语音克隆：工作原理](/docs/zh/eleven-api/concepts/voice-cloning)

了解 IVC 和 PVC 的技术差异及其适用场景。