4Hz / fourhz-focus
Target Speech Recognition · Synchronous · SYNC
Focus transcription on one designated speaker amid noise and overlapping voices.
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> |
Prepare the target voice
Enroll the target voice and use the complete enrollment_id as fourhz_enrollment_id. Do not send speaker_labels or fourhz_identify_candidates; this mode only transcribes the target speaker.
Speaker enrollmentAuthentication
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. |
fourhz_enrollment_id | string | Yes | — | Complete enrollment_id of an enrolled voiceprint identifying the target speaker. |
speaker_vad | boolean | No | false | Optional; defaults to false (disabled). Set true to enable additional voiceprint activity detection; requires fourhz_enrollment_id. |
reject_background_speech | boolean | Set true to enable background speech rejection. | ||
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. |
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. |
fourhz_target_speaker.enrollment_id | string | Target enrollment ID used. |
fourhz_target_speaker.applied | boolean | Target conditioning evidence reported by the model chain. |
fourhz_target_speaker.speaker_vad_applied | boolean? | Whether speaker gating actually took effect. When speaker_vad=true was requested but gating did not apply (for example the voiceprint lacks a verification reference, so all segments are transcribed fail-open), it is false and fourhz_target_speaker.fallback_reason gives the reason (such as speaker_reference_unavailable). |
fourhz_target_speaker.fallback_reason | string? | Present only when gating was requested but speaker_vad_applied=false; explains why. |
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 'fourhz_enrollment_id=enr_example' \
-F 'speaker_vad=false'# 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","fourhz_enrollment_id":"enr_example","speaker_vad":"False"}
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("fourhz_enrollment_id", "enr_example");
body.append("speaker_vad", "false");
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,
"fourhz_target_speaker": {
"enrollment_id": "enr_example",
"applied": true
}
}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. |
Speaker VAD
speaker_vad · boolean
Optional; defaults to false (disabled). Set false to disable auxiliary speaker activity detection. Target-speaker recognition still uses fourhz_enrollment_id; acoustic VAD and duration-based segmentation remain enabled.
"speaker_vad": false