即时语音克隆快速入门

本指南介绍如何使用克隆声音 API 克隆声音。

本指南将介绍如何使用克隆声音 API 创建即时语音克隆。要通过控制台创建即时语音克隆,请参阅即时语音克隆产品指南。

如需深入了解 IVC 和 PVC 的工作原理及其适用场景,请参阅语音克隆:工作原理。

使用即时语音克隆 API

本指南假定你已设置 API 密钥和 SDK。如果尚未设置,请先完成 快速入门。

1

发起 API 请求

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

# 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)
2

执行代码

python example.py

控制台中会显示音色 ID。

后续步骤