Loading...
Loading...
Compare original and translation side by side
POST https://modelslab.com/api/v7/voice/text-to-speechPOST https://modelslab.com/api/v7/voice/speech-to-textPOST https://modelslab.com/api/v7/voice/speech-to-speechPOST https://modelslab.com/api/v7/voice/music-genPOST https://modelslab.com/api/v7/voice/sound-generationPOST https://modelslab.com/api/v7/voice/create-dubbingPOST https://modelslab.com/api/v7/voice/song-extenderPOST https://modelslab.com/api/v7/voice/song-inpaintPOST https://modelslab.com/api/v7/voice/fetch/{id}Note: v6 endpoints (, etc.) still work but v7 is the current version. Parameter names have changed in v7 (e.g.,/api/v6/voice/text_to_speechis nowtext,promptis nowaudio).init_audio
POST https://modelslab.com/api/v7/voice/text-to-speechPOST https://modelslab.com/api/v7/voice/speech-to-textPOST https://modelslab.com/api/v7/voice/speech-to-speechPOST https://modelslab.com/api/v7/voice/music-genPOST https://modelslab.com/api/v7/voice/sound-generationPOST https://modelslab.com/api/v7/voice/create-dubbingPOST https://modelslab.com/api/v7/voice/song-extenderPOST https://modelslab.com/api/v7/voice/song-inpaintPOST https://modelslab.com/api/v7/voice/fetch/{id}注意:v6版本的接口(如等)仍可使用,但v7为当前最新版本。v7版本中部分参数名称已变更(例如:/api/v6/voice/text_to_speech改为text,prompt改为audio)。init_audio
undefinedundefinedundefinedundefined| model_id | Name | Use With |
|---|---|---|
| ElevenLabs Multilingual v2 | text-to-speech |
| ElevenLabs Voice Changer | speech-to-speech |
| ElevenLabs Scribe | speech-to-text |
| ElevenLabs Sound Effects | sound-generation |
| ElevenLabs Music | music-gen |
| Inworld TTS | text-to-speech |
| model_id | 名称 | 适用场景 |
|---|---|---|
| ElevenLabs Multilingual v2 | 文本转语音 |
| ElevenLabs Voice Changer | 语音转语音 |
| ElevenLabs Scribe | 语音转文本 |
| ElevenLabs Sound Effects | 音效生成 |
| ElevenLabs Music | 音乐生成 |
| Inworld TTS | 文本转语音 |
import requests
import time
def text_to_speech(text, api_key, voice_id="21m00Tcm4TlvDq8ikWAM", model_id="eleven_multilingual_v2"):
"""Convert text to speech.
Args:
text: The text to convert to speech
api_key: Your ModelsLab API key
voice_id: ElevenLabs voice ID (see Available Voices below)
model_id: TTS model to use
"""
response = requests.post(
"https://modelslab.com/api/v7/voice/text-to-speech",
json={
"key": api_key,
"prompt": text, # v7 uses "prompt" not "text"
"voice_id": voice_id,
"model_id": model_id
}
)
data = response.json()
if data["status"] == "success":
return data["output"][0]
elif data["status"] == "processing":
return poll_audio_result(data["id"], api_key)
else:
raise Exception(f"Error: {data.get('message', 'Unknown error')}")import requests
import time
def text_to_speech(text, api_key, voice_id="21m00Tcm4TlvDq8ikWAM", model_id="eleven_multilingual_v2"):
"""Convert text to speech.
Args:
text: The text to convert to speech
api_key: Your ModelsLab API key
voice_id: ElevenLabs voice ID (see Available Voices below)
model_id: TTS model to use
"""
response = requests.post(
"https://modelslab.com/api/v7/voice/text-to-speech",
json={
"key": api_key,
"prompt": text, # v7 uses "prompt" not "text"
"voice_id": voice_id,
"model_id": model_id
}
)
data = response.json()
if data["status"] == "success":
return data["output"][0]
elif data["status"] == "processing":
return poll_audio_result(data["id"], api_key)
else:
raise Exception(f"Error: {data.get('message', 'Unknown error')}")undefinedundefineddef speech_to_text(audio_url, api_key, model_id="scribe_v1"):
"""Transcribe speech from audio to text.
Args:
audio_url: URL of audio file (must be publicly accessible)
model_id: STT model to use
"""
response = requests.post(
"https://modelslab.com/api/v7/voice/speech-to-text",
json={
"key": api_key,
"init_audio": audio_url, # v7 uses "init_audio" not "audio"
"model_id": model_id
}
)
data = response.json()
if data["status"] == "success":
return data["output"][0]
elif data["status"] == "processing":
return poll_audio_result(data["id"], api_key)
else:
raise Exception(data.get("message"))def speech_to_text(audio_url, api_key, model_id="scribe_v1"):
"""Transcribe speech from audio to text.
Args:
audio_url: URL of audio file (must be publicly accessible)
model_id: STT model to use
"""
response = requests.post(
"https://modelslab.com/api/v7/voice/speech-to-text",
json={
"key": api_key,
"init_audio": audio_url, # v7 uses "init_audio" not "audio"
"model_id": model_id
}
)
data = response.json()
if data["status"] == "success":
return data["output"][0]
elif data["status"] == "processing":
return poll_audio_result(data["id"], api_key)
else:
raise Exception(data.get("message"))undefinedundefineddef speech_to_speech(audio_url, voice_id, api_key, model_id="eleven_english_sts_v2"):
"""Convert voice characteristics in audio.
Args:
audio_url: URL of the source audio
voice_id: Target ElevenLabs voice ID
model_id: Voice conversion model
"""
response = requests.post(
"https://modelslab.com/api/v7/voice/speech-to-speech",
json={
"key": api_key,
"init_audio": audio_url,
"voice_id": voice_id,
"model_id": model_id
}
)
data = response.json()
if data["status"] == "success":
return data["output"][0]
elif data["status"] == "processing":
return poll_audio_result(data["id"], api_key)def speech_to_speech(audio_url, voice_id, api_key, model_id="eleven_english_sts_v2"):
"""Convert voice characteristics in audio.
Args:
audio_url: URL of the source audio
voice_id: Target ElevenLabs voice ID
model_id: Voice conversion model
"""
response = requests.post(
"https://modelslab.com/api/v7/voice/speech-to-speech",
json={
"key": api_key,
"init_audio": audio_url,
"voice_id": voice_id,
"model_id": model_id
}
)
data = response.json()
if data["status"] == "success":
return data["output"][0]
elif data["status"] == "processing":
return poll_audio_result(data["id"], api_key)def generate_sound_effect(description, api_key, model_id="eleven_sound_effect"):
"""Generate a sound effect from a text description.
Args:
description: What sound to generate
model_id: Sound effects model
"""
response = requests.post(
"https://modelslab.com/api/v7/voice/sound-generation",
json={
"key": api_key,
"prompt": description,
"model_id": model_id
}
)
data = response.json()
if data["status"] == "success":
return data["output"][0]
elif data["status"] == "processing":
return poll_audio_result(data["id"], api_key)def generate_sound_effect(description, api_key, model_id="eleven_sound_effect"):
"""Generate a sound effect from a text description.
Args:
description: What sound to generate
model_id: Sound effects model
"""
response = requests.post(
"https://modelslab.com/api/v7/voice/sound-generation",
json={
"key": api_key,
"prompt": description,
"model_id": model_id
}
)
data = response.json()
if data["status"] == "success":
return data["output"][0]
elif data["status"] == "processing":
return poll_audio_result(data["id"], api_key)undefinedundefineddef generate_music(prompt, api_key, model_id="music_v1"):
"""Generate music from a text description.
Args:
prompt: Description of music style/mood
model_id: Music generation model
"""
response = requests.post(
"https://modelslab.com/api/v7/voice/music-gen",
json={
"key": api_key,
"prompt": prompt,
"model_id": model_id
}
)
data = response.json()
if data["status"] == "success":
return data["output"][0]
elif data["status"] == "processing":
return poll_audio_result(data["id"], api_key)def generate_music(prompt, api_key, model_id="music_v1"):
"""Generate music from a text description.
Args:
prompt: Description of music style/mood
model_id: Music generation model
"""
response = requests.post(
"https://modelslab.com/api/v7/voice/music-gen",
json={
"key": api_key,
"prompt": prompt,
"model_id": model_id
}
)
data = response.json()
if data["status"] == "success":
return data["output"][0]
elif data["status"] == "processing":
return poll_audio_result(data["id"], api_key)undefinedundefineddef poll_audio_result(request_id, api_key, timeout=300):
"""Poll for async audio generation results."""
start_time = time.time()
while time.time() - start_time < timeout:
fetch = requests.post(
f"https://modelslab.com/api/v7/voice/fetch/{request_id}",
json={"key": api_key}
)
result = fetch.json()
if result["status"] == "success":
return result["output"][0]
elif result["status"] == "failed":
raise Exception(result.get("message", "Generation failed"))
time.sleep(5)
raise Exception("Timeout waiting for audio generation")def poll_audio_result(request_id, api_key, timeout=300):
"""Poll for async audio generation results."""
start_time = time.time()
while time.time() - start_time < timeout:
fetch = requests.post(
f"https://modelslab.com/api/v7/voice/fetch/{request_id}",
json={"key": api_key}
)
result = fetch.json()
if result["status"] == "success":
return result["output"][0]
elif result["status"] == "failed":
raise Exception(result.get("message", "Generation failed"))
time.sleep(5)
raise Exception("Timeout waiting for audio generation")| Voice ID | Name | Style |
|---|---|---|
| Rachel | Neutral, calm |
| Domi | Confident |
| Bella | Soft, warm |
| Antoni | Well-rounded |
| Elli | Young, clear |
| Josh | Deep, warm |
| Arnold | Strong |
| Adam | Deep, narrative |
| Sam | Dynamic |
| 语音ID | 名称 | 风格 |
|---|---|---|
| Rachel | 中性、沉稳 |
| Domi | 自信 |
| Bella | 柔和、温暖 |
| Antoni | 全面均衡 |
| Elli | 年轻、清晰 |
| Josh | 低沉、温暖 |
| Arnold | 强劲有力 |
| Adam | 低沉、叙事感 |
| Sam | 富有活力 |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Text to convert to speech |
| string | Yes | ElevenLabs voice identifier |
| string | Yes | TTS model (e.g., |
| float | No | Voice variation |
| string | No | Async notification URL |
| 参数 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| string | 是 | 要转换为语音的文本 |
| string | 是 | ElevenLabs语音标识符 |
| string | 是 | TTS模型(例如: |
| float | 否 | 语音变化程度 |
| string | 否 | 异步通知URL |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | URL of audio to transcribe |
| string | Yes | STT model (e.g., |
| 参数 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| string | 是 | 要转录的音频URL |
| string | 是 | STT模型(例如: |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Sound effect description |
| string | Yes | SFX model (e.g., |
| 参数 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| string | 是 | 音效描述文本 |
| string | 是 | 音效模型(例如: |
| v6 Parameter | v7 Parameter | Notes |
|---|---|---|
| | TTS text input |
| | STT/STS audio input |
| | Voice-to-voice source |
| (not required) | | Now required on all endpoints |
| v6 参数 | v7 参数 | 说明 |
|---|---|---|
| | TTS文本输入 |
| | STT/STS音频输入 |
| | 语音转换的源音频 |
| (非必填) | | 现在所有接口均为必填项 |
payload = {
"key": api_key,
"prompt": "...",
"model_id": "eleven_multilingual_v2",
"webhook": "https://yourserver.com/webhook/audio",
"track_id": "audio_001"
}payload = {
"key": api_key,
"prompt": "...",
"model_id": "eleven_multilingual_v2",
"webhook": "https://yourserver.com/webhook/audio",
"track_id": "audio_001"
}try:
audio = text_to_speech(text, api_key)
print(f"Audio generated: {audio}")
except Exception as e:
print(f"Audio generation failed: {e}")try:
audio = text_to_speech(text, api_key)
print(f"Audio generated: {audio}")
except Exception as e:
print(f"Audio generation failed: {e}")modelslab-model-discoverymodelslab-video-generationmodelslab-chat-generationmodelslab-webhooksmodelslab-model-discoverymodelslab-video-generationmodelslab-chat-generationmodelslab-webhooks