快速入门
向本地 VoiceStudio API 发送你的第一个语音请求。
仅适用于本地 API
本指南适用于桌面应用的 0.5.0 API。Cloud API 尚未发布,工作方式也不同;请参阅 Cloud 预览。
1. 启动应用
打开 VoiceStudio。应用运行时,其 API 监听 3900 端口。
export VOICESTUDIO_BASE_URL="http://localhost:3900/v1"
export VOICESTUDIO_API_KEY="local"
curl http://localhost:3900/health{
"status": "ok",
"device": "cuda (NVIDIA GeForce RTX 4090)",
"version": "0.5.0"
}在 localhost 上,密钥可以是任意非空字符串。只有启用远程访问时才会检查密钥。
2. 生成语音
curl "$VOICESTUDIO_BASE_URL/audio/speech" \
-H "Authorization: Bearer $VOICESTUDIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"voice": "alloy",
"input": "VoiceStudio is ready.",
"response_format": "mp3"
}' \
--output speech.mp33. 或使用 OpenAI SDK
import os
from openai import OpenAI
client = OpenAI(
base_url=os.environ["VOICESTUDIO_BASE_URL"],
api_key=os.environ["VOICESTUDIO_API_KEY"],
)
audio = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="The local VoiceStudio API is ready.",
)
audio.stream_to_file("speech.mp3")下一步:将 alloy 替换为你自己的某个声音配置 ID。