Voiceprint Management
Register and manage voiceprints for target-speaker transcription and speaker identification.
Create a voiceprint
POST https://api.fourhz.ai/v1/speaker-enrollments
Header: Authorization: <API Key>; use the raw API key without Bearer.
Submit one 5–10 second clip by default. The browser trims longer uploads to the first continuous 10 seconds; the service validates it and uses the first continuous 5 seconds. Normalize enrollment audio to 16 kHz mono 16-bit PCM WAV with a WAV header. Direct API clients should convert before upload and must not send the headerless raw PCM16LE used by the realtime WebSocket API. Legacy three-clip uploads remain supported at 1–8 seconds per clip.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
audio | file × 1 | Yes · Multipart | Use 16 kHz mono 16-bit PCM WAV with a WAV header. One 5–10 second clip; for the legacy format repeat audio three times, 1–8 seconds each. |
audio_format | string | No · Multipart | Usually omitted; provide one hint per clip for the legacy three-clip format. |
name | string | No · Multipart | Display name, at most 64 characters. |
scope | string | No · Multipart | Defaults to user; api_key restricts use to the current key. |
Response fields
| Field | Type | Description |
|---|---|---|
enrollment_id | string | Complete voiceprint ID; reuse unchanged for lookups, deletion and transcription. |
status | string | Successful creation returns ready. A failed registration returns an error, never a usable voiceprint. |
member_count | integer | Number of reference clips. |
name | string? | Optional display name, not an identity match. |
scope | string? | user shares within the account; api_key restricts use to the creating key. |
created_at | string? | Creation time in RFC3339. Legacy voiceprints may omit metadata. |
Request examples
curl -X POST 'https://api.fourhz.ai/v1/speaker-enrollments' \
-H "Authorization: $FOURHZ_API_KEY" \
-F 'audio=@speaker.wav' \
-F 'name=Alice' \
-F 'scope=user'# pip install requests
import os
import requests
from contextlib import ExitStack
url = "https://api.fourhz.ai/v1/speaker-enrollments"
headers = {"Authorization": os.environ["FOURHZ_API_KEY"]}
with ExitStack() as stack:
files = [
("audio", ("speaker.wav", stack.enter_context(open("speaker.wav", "rb"))))
]
fields = {"name":"Alice","scope":"user"}
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/speaker-enrollments";
const headers = {"Authorization": process.env.FOURHZ_API_KEY};
const body = new FormData();
body.append("audio", new Blob([await readFile("speaker.wav")]), "speaker.wav");
body.append("name", "Alice");
body.append("scope", "user");
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());Response example
HTTP 200
{
"enrollment_id": "enr_example",
"status": "ready",
"member_count": 3,
"name": "Alice",
"scope": "user",
"created_at": "2026-10-16T00:00:00Z"
}Enrollment quality checks and error codes
Single-clip enrollment checks audio level, active speech, and clipping; legacy three-clip enrollment also checks speaker consistency. A failed quality check rejects registration without returning a usable voiceprint. Do not treat an error as success. Record again according to the error; repeatedly submitting the same unsuitable audio will not improve it.
Quality-check errors return HTTP 422; empty audio, duration, and decoding errors return HTTP 400 (see the table). Branch on error_code; message explains the problem and should not be parsed for program logic.
| HTTP | error_code | Cause and recommended action |
|---|---|---|
| 422 | low_quality | Usable speech does not meet the recording quality requirements, for example because it is too faint or distorted. Record again in a quiet environment at a clear, moderate level without clipping. |
| 422 | audio_too_quiet | The recording is too quiet. Move closer to the microphone, raise the input level, and record again. |
| 422 | insufficient_speech | Too little active speech or too many pauses. Record clear, continuous speech with less silence. |
| 422 | audio_clipped | The recording is clipped. Lower the input gain or increase microphone distance, then record again. |
| 422 | speaker_samples_inconsistent | Speaker characteristics differ across the three clips. Record the same speaker alone, avoiding cross-talk and overlapping voices. |
| 400 | too_short | The clip or its usable speech is too short. Record again within the duration limits with enough clear speech. |
| 400 | empty | The audio is empty. Record again or select a file that contains audio. |
| 400 | unsupported_format | The audio format is unsupported. Use a supported format and check audio_format. |
| 400 | decode_failed | The audio cannot be decoded. Check that the file is complete and its format hint is correct, or export it again. |
A temporary service failure returns 503 and does not mean the recording failed a quality check. Retry later; do not substitute an existing voiceprint for the failed registration.
When the problem can be attributed to one clip, audio_index is its zero-based upload index: 0, 1, and 2 identify the first, second, and third clips. If attribution is unreliable, such as an inconsistent group, the field is omitted. Review or record all three clips again instead of guessing which clip failed.
{
"error_code": "audio_too_quiet",
"message": "The reference audio is too quiet. Record it again at a clear speaking volume.",
"audio_index": 0
}Errors
| HTTP | Description |
|---|---|
| 401 | Missing or invalid API key in the header. |
| 503 | Service temporarily unavailable; retry later. |
List voiceprints
GET https://api.fourhz.ai/v1/speaker-enrollments
Header: Authorization: <API Key>; use the raw API key without Bearer.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | No · Query | Search for a substring in name or enrollment_id. |
scope | string | No · Query | user or api_key; omit to list all voiceprints accessible to this credential. |
limit | integer | No · Query | Default 20, maximum 100. |
offset | integer | No · Query | Number of records to skip, default 0. |
Response fields
| Field | Type | Description |
|---|---|---|
enrollments | array | Accessible voiceprints, newest first. |
enrollments[].status | string | Empty in list responses. Query details to determine availability. |
enrollments[].enrollment_id | string | Complete voiceprint ID; reuse unchanged for lookups, deletion and transcription. |
enrollments[].member_count | integer | Number of reference clips. |
enrollments[].name | string? | Optional display name, not an identity match. |
enrollments[].scope | string? | user shares within the account; api_key restricts use to the creating key. |
enrollments[].created_at | string? | Creation time in RFC3339. Legacy voiceprints may omit metadata. |
total | integer | Total matching record count. |
limit / offset | integer | Effective page size and offset. |
Request examples
curl -X GET 'https://api.fourhz.ai/v1/speaker-enrollments?limit=20&offset=0' \
-H "Authorization: $FOURHZ_API_KEY"# pip install requests
import os
import requests
from contextlib import ExitStack
url = "https://api.fourhz.ai/v1/speaker-enrollments?limit=20&offset=0"
headers = {"Authorization": os.environ["FOURHZ_API_KEY"]}
with ExitStack() as stack:
response = requests.request("GET", url, headers=headers, timeout=300)
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/speaker-enrollments?limit=20&offset=0";
const headers = {"Authorization": process.env.FOURHZ_API_KEY};
const response = await fetch(url, {method: "GET", headers, signal: AbortSignal.timeout(300000)});
if (!response.ok) throw new Error(await response.text());
console.log(response.status === 204 ? {status: 204} : await response.json());Response example
HTTP 200
{
"enrollments": [
{
"enrollment_id": "enr_example",
"status": "",
"member_count": 3,
"name": "Alice",
"scope": "user",
"created_at": "2026-10-16T00:00:00Z"
}
],
"total": 1,
"limit": 20,
"offset": 0
}Errors
| HTTP | Description |
|---|---|
| 401 | Missing or invalid API key in the header. |
| 503 | Service temporarily unavailable; retry later. |
Get voiceprint details
GET https://api.fourhz.ai/v1/speaker-enrollments/{enrollment_id}
Header: Authorization: <API Key>; use the raw API key without Bearer.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
enrollment_id | string | Yes · Path | Complete ID returned at creation. Unknown, deleted and inaccessible IDs all return HTTP 404. |
Response fields
| Field | Type | Description |
|---|---|---|
enrollment_id | string | Complete voiceprint ID; reuse unchanged for lookups, deletion and transcription. |
status | string | Details return ready or unknown; only ready means available. |
member_count | integer | Number of reference clips. |
name | string? | Optional display name, not an identity match. |
scope | string? | user shares within the account; api_key restricts use to the creating key. |
created_at | string? | Creation time in RFC3339. Legacy voiceprints may omit metadata. |
Request examples
curl -X GET 'https://api.fourhz.ai/v1/speaker-enrollments/enr_example' \
-H "Authorization: $FOURHZ_API_KEY"# pip install requests
import os
import requests
from contextlib import ExitStack
url = "https://api.fourhz.ai/v1/speaker-enrollments/enr_example"
headers = {"Authorization": os.environ["FOURHZ_API_KEY"]}
with ExitStack() as stack:
response = requests.request("GET", url, headers=headers, timeout=300)
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/speaker-enrollments/enr_example";
const headers = {"Authorization": process.env.FOURHZ_API_KEY};
const response = await fetch(url, {method: "GET", headers, signal: AbortSignal.timeout(300000)});
if (!response.ok) throw new Error(await response.text());
console.log(response.status === 204 ? {status: 204} : await response.json());Response example
HTTP 200
{
"enrollment_id": "enr_example",
"status": "ready",
"member_count": 3,
"name": "Alice",
"scope": "user",
"created_at": "2026-10-16T00:00:00Z"
}Errors
| HTTP | Description |
|---|---|
| 401 | Missing or invalid API key in the header. |
| 404 | Voiceprint does not exist, was deleted, or is outside the credential scope. |
| 503 | Service temporarily unavailable; retry later. |
Delete a voiceprint
DELETE https://api.fourhz.ai/v1/speaker-enrollments/{enrollment_id}
Header: Authorization: <API Key>; use the raw API key without Bearer.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
enrollment_id | string | Yes · Path | Complete ID returned at creation. Unknown, deleted and inaccessible IDs all return HTTP 404. |
Response fields
HTTP 204 with no body. The voiceprint and reference audio are removed; subsequent lookup or deletion returns HTTP 404.
Request examples
curl -X DELETE 'https://api.fourhz.ai/v1/speaker-enrollments/enr_example' \
-H "Authorization: $FOURHZ_API_KEY"# pip install requests
import os
import requests
from contextlib import ExitStack
url = "https://api.fourhz.ai/v1/speaker-enrollments/enr_example"
headers = {"Authorization": os.environ["FOURHZ_API_KEY"]}
with ExitStack() as stack:
response = requests.request("DELETE", url, headers=headers, timeout=300)
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/speaker-enrollments/enr_example";
const headers = {"Authorization": process.env.FOURHZ_API_KEY};
const response = await fetch(url, {method: "DELETE", headers, signal: AbortSignal.timeout(300000)});
if (!response.ok) throw new Error(await response.text());
console.log(response.status === 204 ? {status: 204} : await response.json());Response example
HTTP 204
A successful response has no body; do not parse JSON.
Errors
| HTTP | Description |
|---|---|
| 401 | Missing or invalid API key in the header. |
| 404 | Voiceprint does not exist, was deleted, or is outside the credential scope. |
| 503 | Service temporarily unavailable; retry later. |