Request parameters
AuthorizationstringRequiredBearer sk-zerofa-xxxContent-TypestringRequiredapplication/jsonmodelstringRequired<tts-model>inputstringRequiredHello, this is a ZeroFA text-to-speech test.voicestringOptionalCherryresponse_formatstringOptionalmp3speednumberOptional1.0Billing model
Billed by input character count, not duration or tokens. Failed requests are not charged.
Speech to text (STT)
/v1/audio/transcriptionsUpload an audio file with multipart and receive a transcript, billed by audio duration. response_format supports json, text, and verbose_json. Use paraformer-realtime-v2 for Paraformer real-time speech recognition.
curl https://zerofa.ai/v1/audio/transcriptions \
-H "Authorization: Bearer sk-zerofa-xxx" \
-F "model=paraformer-realtime-v2" \
-F "file=@audio.wav" \
-F "response_format=json"Real-time transcription (WebSocket)
/v1/audio/transcriptions/realtimeSend PCM16 mono binary audio frames after connecting. The server emits transcript.delta and transcript.completed events, then session.completed after input_audio_buffer.commit.
import json
import time
import websocket
url = (
"wss://zerofa.ai/v1/audio/transcriptions/realtime"
"?model=paraformer-realtime-v2&format=pcm"
"&sample_rate=16000&language=zh&max_duration_seconds=60"
)
ws = websocket.create_connection(
url,
header=["Authorization: Bearer sk-zerofa-xxx"],
timeout=90,
)
print(json.loads(ws.recv())) # session.created
with open("audio.pcm", "rb") as audio:
while chunk := audio.read(3200): # 100ms PCM16 mono 16kHz
ws.send_binary(chunk)
time.sleep(0.1)
ws.send(json.dumps({"type": "input_audio_buffer.commit"}))
while True:
event = json.loads(ws.recv())
print(event)
if event["type"] in {"session.completed", "error"}:
break
ws.close()Available models
See TTS models in the Model Catalog and filter for Audio. The model in the sample is a placeholder. If no matching model is listed, TTS is not currently available.
Request and response bodies
Use the examples below to verify the request and response structures. To send a request, select Debug at the top of the page.
curl https://zerofa.ai/v1/audio/speech \
-H "Authorization: Bearer sk-zerofa-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "<tts-model>",
"input": "Hello, this is a ZeroFA text-to-speech test.",
"voice": "Cherry"
}' \
--output speech.wav