4Hz / fourhz-focus
Speaker Diarization · Synchronous · SYNC
Distinguish speakers and label each contribution.
Realtime · RTT · Pre-recorded · PRE · Synchronous · SYNC
Sync accepts up to 30 seconds; use the Pre-recorded API for longer audio.
Service endpoints
Service URL: https://api.fourhz.ai
| Method / Protocol | Path | Content-Type / Frames | Auth |
|---|---|---|---|
| POST | /v1/asr/sync | multipart/form-data | Authorization: <API Key> |
Two variants
Diarization only
speaker_labels=true returns anonymous roles without enrollment.
Diarization + speaker identification
Keep speaker_labels=true and supply fourhz_identify_candidates. Create candidates using enrollment. An unknown result or best_candidate is not a confirmed identity.
Speaker enrollmentSYNC currently supports diarization only and does not accept fourhz_identify_candidates. Use this feature’s RTT or PRE endpoint for integrated speaker identification.
Authentication
Use the raw API key without Bearer. Put it in the HTTP Authorization header; keep long-lived keys on the server.
Authorization: $FOURHZ_API_KEY
Request parameters
| Field | Type | Required | Description | |
|---|---|---|---|---|
model | string | Yes | fourhz-focus | Select the speech recognition model for this endpoint. |
speaker_labels | boolean | Yes | true | Set true to separate speakers and return anonymous speaker labels. |
audio | file | Yes | WAV or raw PCM16LE; 80 ms–30 s, up to 40 MB. | |
channels | integer | PCM only | Must be 1. | |
language_codes | string | No | zh or en; omit for auto-detection. | |
keyterms_prompt | string | No | Up to 100 comma-separated terms. | |
fourhz_cleanup_level | string | No | off (default), light, or standard. | |
fourhz_translate_mode | boolean | No | Enables translation and requires a target language when true. | |
fourhz_target_language | string | Conditional | Translation target, for example en. | |
fourhz_text_emotion | boolean | No | Uses speech emotion during text post-processing. | |
fourhz_hotword_pool_id | string | No | An existing hotword pool ID. | |
reject_background_speech | boolean | No | Background-speech rejection. Optional; defaults to true (enabled). Set to false to disable. multipart/form-data field; also accepted inside the config JSON. |
Response fields
| Field | Type | Meaning and availability |
|---|---|---|
text | string | Full transcript; target mode contains the target speaker’s output. |
audio_duration_ms | number | SYNC processed audio duration in milliseconds. |
session_id | string | SYNC task/correlation ID. |
request_time_ms | number | SYNC server processing time in milliseconds. |
error_code | string | Stable error code on failure. |
message | string | Human-readable error message. |
speaker_label / utterances[].speaker | string | Anonymous role A/B/… or UNKNOWN, not a real-person identity. |
utterances[].start / end | integer | PRE/SYNC utterance start/end in milliseconds. |
utterances[].text | string | Text of this speaker’s utterance. |
Request examples
Code samples
curl -X POST 'https://api.fourhz.ai/v1/asr/sync' \
-H "Authorization: $FOURHZ_API_KEY" \
-F 'audio=@sample.wav' \
-F 'model=fourhz-focus' \
-F 'speaker_labels=true'# pip install requests
import os
import requests
from contextlib import ExitStack
url = "https://api.fourhz.ai/v1/asr/sync"
headers = {"Authorization": os.environ["FOURHZ_API_KEY"]}
with ExitStack() as stack:
files = [
("audio", ("sample.wav", stack.enter_context(open("sample.wav", "rb"))))
]
fields = {"model":"fourhz-focus","speaker_labels":"True"}
response = requests.request("POST", url, headers=headers, timeout=300, files=files, data=fields)
response.raise_for_status()
print(response.json() if response.content else {"status": response.status_code})// Node.js 22+
import {readFile} from 'node:fs/promises';
const url = "https://api.fourhz.ai/v1/asr/sync";
const headers = {"Authorization": process.env.FOURHZ_API_KEY};
const body = new FormData();
body.append("audio", new Blob([await readFile("sample.wav")]), "sample.wav");
body.append("model", "fourhz-focus");
body.append("speaker_labels", "true");
const response = await fetch(url, {method: "POST", headers, body, signal: AbortSignal.timeout(300000)});
if (!response.ok) throw new Error(await response.text());
console.log(response.status === 204 ? {status: 204} : await response.json());Sending and receiving
Response and results
{
"text": "Hello world.",
"audio_duration_ms": 4200,
"session_id": "task-example",
"request_time_ms": 1834.6,
"utterances": [
{
"speaker": "A",
"text": "Hello world.",
"start": 0,
"end": 4200
}
]
}Error codes
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.
HTTP values are status codes. Except for detail responses such as 401/402, the body uses {"error_code":"…","message":"…"}. These codes apply to the synchronous API.
| HTTP | Response code | Meaning |
|---|---|---|
| HTTP 400 | bad_audio / audio_too_short / invalid_candidates | Audio cannot be decoded, is too short, or the candidate voiceprint set is invalid. |
| HTTP 401 | detail | Missing or invalid API key. |
| HTTP 402 | detail | Insufficient balance. |
| HTTP 413 | audio_too_large | Decoded audio exceeds the duration limit. |
| HTTP 415 | unsupported_media_type | Unsupported container format, or the file content is not audio (for example a text file renamed to .mp3). |
| HTTP 422 | unsupported_capability / enrollment_* | The selected model/capability is unavailable, or enrollment constraints are not met. |
| HTTP 429 | capacity_exceeded | Capacity is currently exhausted; follow Retry-After. |
| HTTP 500/504 | inference_error / inference_timeout | Upstream inference failed or exceeded the wait budget. |
| HTTP 503 | service_unavailable | The selected backend is unavailable. |