Try this endpoint →

Service endpoints

Service URL: https://api.fourhz.ai

Method / ProtocolPathContent-Type / FramesAuth
POST/v1/emotion-captioning/syncmultipart/form-dataAuthorization: <API Key>

Request parameters

Returns the final result with HTTP 200, never a pending task_id. PCM WAV only, 80 ms–15 seconds, maximum 20 MiB. Server processing waits up to 120 seconds. A normal synchronous call returns its final result without polling. A timeout or disconnect does not prove cancellation; do not retry blindly. Keep any job_id or X-Job-Id for investigation, and query a task only when its ID is available.

audio: audio file; mode: sec (default, natural-language captions) or ser (label classification); language: result language hint, such as zh or en.

ParameterTypeRequiredDescription
audiofileYesPCM WAV audio to analyze, 80 ms–15 seconds, maximum 20 MiB.
modestringNosec (default, natural-language caption) or ser (label classification).
languagestringNoLanguage hint, for example zh or en.

Response fields

FieldTypeDescription
statusstringsucceeded on success.
resultobjectFinal emotion captioning result.
result.typestring?final_emotion identifies an emotion result.
result.modestringsec for natural-language captions; ser for label classification.
result.textstring?Emotion caption returned by the model.
result.labelstring?Emotion label when returned; absence does not imply neutral.
result.duration_secnumberProcessed duration in seconds.
result.languagestring?Result language when returned.

Request examples

Python uses requests. JavaScript file examples use Node.js 22+. Long-lived keys are server-side only.

curl -X POST 'https://api.fourhz.ai/v1/emotion-captioning/sync' \
  -H "Authorization: $FOURHZ_API_KEY" \
  -F 'audio=@audio.wav' \
  -F 'mode=sec' \
  -F 'language=zh'

Response examples

HTTP 200 returns the final result directly; no polling. Scores and text illustrate the response structure.

{
  "status": "succeeded",
  "result": {
    "type": "final_emotion",
    "mode": "sec",
    "label": "Happy",
    "text": "The speaker sounds excited and cheerful.",
    "duration_sec": 2.68,
    "language": "en"
  }
}

Errors

Every HTTP error body contains error_code (machine-readable) and message (human-readable). Legacy fields such as detail, code/msg or an upstream error object are kept and status codes are unchanged. Clients should read error_code and message first.

Common statuses: 400 invalid parameters or audio; 401 authentication failed; 402 insufficient balance; 413 file too large; 415 file content is not supported audio; 429 rate limit or capacity full (honor Retry-After); 503 service not configured or unavailable.