Chapter 9 of 211 min

9. Audio#

9.1 Speech synthesis (TTS)#

POST /v1/audio/speech — text to speech; returns an audio byte stream (e.g. audio/mpeg) that can be written directly to a file.

ParameterTypeRequiredDescription
modelstringYesTTS model name
inputstringYesText to synthesize
voicestringNoVoice
cURL
curl http://183.240.79.21:52099/v1/audio/speech \
  -H "Authorization: Bearer sk-你的YiTuoToken-Key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "你好,欢迎使用 YiTuoToken",
    "voice": "alloy"
  }' \
  --output speech.mp3

9.2 Speech recognition (STT)#

POST /v1/audio/transcriptions — speech to text (Whisper). The audio file is uploaded with multipart/form-data.

FieldRequiredDescription
fileYesAudio file
modelYesRecognition model name
languageNoLanguage code, e.g. zh
promptNoPrompt
response_formatNoResponse format
temperatureNoSampling temperature
cURL
curl http://183.240.79.21:52099/v1/audio/transcriptions \
  -H "Authorization: Bearer sk-你的YiTuoToken-Key" \
  -F file=@./audio.mp3 \
  -F model="whisper-1" \
  -F language="zh"