语音

语音合成、识别与翻译走 OpenAI 的 /v1/audio/* 路径。不写代码想先听一下效果,可以用控制台的语音页。

语音合成

POST /v1/audio/speech,input 是文本,voice 是音色名(各家可用的音色不同),response_format 支持 mp3、wav、opus、aac 等;响应体直接是音频文件。按输入字符数计费。

POST /v1/audio/speech
curl https://inferstream.cn/v1/audio/speech \
  -H "Authorization: Bearer $INFERSTREAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "你好,欢迎使用 InferStream。",
    "voice": "alloy",
    "response_format": "mp3"
  }' \
  --output speech.mp3

语音识别与翻译

POST /v1/audio/transcriptions,multipart 上传音频文件与模型名,返回识别文字;POST /v1/audio/translations 参数相同,输出英文译文。按上游返回的用量计费,通常对应音频时长。请求体上限 16 MB。

POST /v1/audio/transcriptions
curl https://inferstream.cn/v1/audio/transcriptions \
  -H "Authorization: Bearer $INFERSTREAM_API_KEY" \
  -F model="whisper-1" \
  -F file="@meeting.m4a"
响应
{ "text": "今天的会议主要讨论了三件事……" }