IndexTTS-2-Demo
IndexTTS2 是由Bilibili 开发的下一代文本转语音模型,于2025年9月8日正式开源。 该模型在情感表达和时长控制方面实现重大突破,被社区誉为"最逼真、最具表现力的TTS 模型"。
API 使用示例
A100(80G)
curl -X POST "https://pumpkinai.space/api/v1/spaces/run" \
-H "Authorization: Bearer YOUR_API_KEY_PLACEHOLDER" \
-H "Content-Type: application/json" \
-d '{
"space_name": "IndexTTS-2-Demo",
"gpu_template": "A100(80G)",
"prompt": "Your creative prompt here"
}'
import requests
import time
import json
API_KEY = "YOUR_API_KEY_PLACEHOLDER"
BASE_URL = "https://pumpkinai.space/api/v1"
PAYLOAD = {
"space_name": "IndexTTS-2-Demo",
"gpu_template": "A100(80G)",
"prompt": "Your creative prompt here"
}
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# 1. Start task
print(">>> Starting task...")
start_response = requests.post(f"{BASE_URL}/spaces/run", json=PAYLOAD, headers=headers)
start_response.raise_for_status()
task_id = start_response.json()["task_id"]
print(f"Task started successfully, Task ID: {task_id}")
# 2. Poll for status
print("\n>>> Polling for status...")
while True:
status_response = requests.get(f"{BASE_URL}/task/{task_id}/status", headers=headers)
status_response.raise_for_status()
data = status_response.json()
status = data.get("status")
print(f"Current task status: {status}")
if status in ["completed", "failed"]:
print("\n--- Task Finished ---")
print(json.dumps(data, indent=2, ensure_ascii=False))
break
time.sleep(5)
import requests
import json
API_KEY = "YOUR_API_KEY_PLACEHOLDER"
BASE_URL = "https://pumpkinai.space/api/v1"
PAYLOAD = {
"space_name": "IndexTTS-2-Demo",
"gpu_template": "A100(80G)",
"prompt": "Your creative prompt here",
"stream": True
}
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
print(">>> Starting stream...")
with requests.post(f"{BASE_URL}/spaces/run", json=PAYLOAD, headers=headers, stream=True) as response:
response.raise_for_status()
for line in response.iter_lines():
if line:
print(line.decode('utf-8'))