Vericlient¶
A Python client for the Veridas APIs. It handles the request plumbing, validates what goes in and out, and turns API errors into exceptions you can actually catch, so integrating a Veridas service does not start with writing a client.
Install¶
Python 3.11 or newer.
Quickstart¶
Check that the service is reachable:
from vericlient import DaspeakClient
client = DaspeakClient(apikey="your_api_key")
print(client.alive())
Enrol a voice and compare another recording against it:
from vericlient import DaspeakClient
client = DaspeakClient(apikey="your_api_key")
# A credential is the biometric representation of a voice. Generate one with the most
# recent model the service offers.
model = client.get_models().models[-1]
credential = client.generate_credential(audio="/path/to/enrolment.wav", hash=model).credential
# Later, compare a new recording against it.
result = client.compare_credential_to_audio(
credential_reference=credential,
audio_to_evaluate="/path/to/verification.wav",
)
print(f"Similarity: {result.score}")
Both audio and audio_to_evaluate accept a path or a bytes object, so nothing has to
touch the filesystem:
with open("/path/to/enrolment.wav", "rb") as f:
credential = client.generate_credential(audio=f.read(), hash=model).credential
Handling failures¶
Everything the client raises inherits from VeriClientError, and the specific exceptions
tell you what to fix:
from vericlient.daspeak.exceptions import NetSpeechDurationIsNotEnoughError
from vericlient.exceptions import VeriClientError
try:
client.generate_credential(audio=recording, hash=model)
except NetSpeechDurationIsNotEnoughError as error:
print(f"Ask for a longer recording: {error}")
except VeriClientError as error:
print(f"Something else went wrong: {error}")
See Error handling for the full list.
Pointing somewhere else¶
By default the client talks to the European sandbox. Switch environment and location, or give it a self-hosted URL and it will skip the cloud entirely:
from vericlient import DaspeakClient
production = DaspeakClient(apikey="your_api_key", environment="production", location="us")
self_hosted = DaspeakClient(
url="https://veridas.internal.example.com/daspeak/v1",
headers={"Authorization": "Bearer your-token"},
)
A self-hosted URL is used exactly as given, and the apikey does not apply to it — that one is
the Veridas cloud's authentication, so a deployment you run yourself authenticates through
headers instead. See Self-hosted deployments.
Every setting can also come from the environment. See Configuration.
Where to next¶
- Supported endpoints — what is covered, per API
- Configuration — targets, environments and settings
- Error handling — the exception tree
- Usage, per client: das-Peak, VCSP and das-Face
- Runnable examples in
scripts/, one per client, covering every endpoint it supports