das-Peak
vericlient.daspeak.client.DaspeakClient
¶
Bases: Client
Class to interact with the Daspeak API.
Source code in src/vericlient/daspeak/client.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | |
alive
¶
Check if the service is alive.
Returns bool: True if the service is alive, False otherwise
Source code in src/vericlient/daspeak/client.py
get_models
¶
Get the models available biometrics models in the service.
Returns:
| Type | Description |
|---|---|
ModelsOutput
|
The response from the service |
Source code in src/vericlient/daspeak/client.py
get_model_metadata
¶
Get the metadata of a biometrics model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hash
|
str
|
The hash of the model to describe |
required |
Returns:
| Type | Description |
|---|---|
GetModelMetadataOutput
|
The response from the service |
Raises:
| Type | Description |
|---|---|
ModelNotAvailableError
|
If no model exists with that hash |
Source code in src/vericlient/daspeak/client.py
get_model_calibrations
¶
Get the calibration modes a biometrics model supports.
Any of the returned values is valid as the calibration argument of
generate_credential and of the comparison inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hash
|
str
|
The hash of the model to list the calibrations of |
required |
Returns:
| Type | Description |
|---|---|
GetModelCalibrationsOutput
|
The response from the service |
Raises:
| Type | Description |
|---|---|
ModelNotAvailableError
|
If no model exists with that hash |
Source code in src/vericlient/daspeak/client.py
get_model_metadata_from_credential
¶
Get the metadata of the model a credential was generated with.
Useful to find out whether a stored credential is still compatible with the models the service currently offers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential
|
str
|
The credential to read the originating model from |
required |
Returns:
| Type | Description |
|---|---|
GetModelMetadataFromCredentialOutput
|
The response from the service |
Raises:
| Type | Description |
|---|---|
InvalidCredentialError
|
If the credential is not valid |
Source code in src/vericlient/daspeak/client.py
generate_credential
¶
generate_credential(
audio, hash, channel=1, calibration=DEFAULT_CALIBRATION
)
Generate a credential from a WAV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio
|
str | bytes
|
The recording, as a path or as bytes |
required |
hash
|
str
|
The hash of the biometrics model to use, from |
required |
channel
|
int
|
Which channel to read, when the recording is stereo |
1
|
calibration
|
str
|
The calibration to use, from |
DEFAULT_CALIBRATION
|
Returns:
| Type | Description |
|---|---|
GenerateCredentialOutput
|
The response from the service |
Raises:
| Type | Description |
|---|---|
TooManyAudioChannelsError
|
If the audio has more channels than the service supports |
UnsupportedAudioCodecError
|
If the audio has an unsupported codec |
UnsupportedSampleRateError
|
If the audio has an unsupported sample rate |
AudioDurationTooLongError
|
If the audio duration is longer than the service supports |
SignalNoiseRatioError
|
If the signal-to-noise ratio is too low |
NetSpeechDurationIsNotEnoughError
|
If the net speech duration is not enough |
InvalidSpecifiedChannelError
|
If the specified channel is invalid |
InsufficientQualityError
|
If the audio quality is insufficient |
CalibrationNotAvailableError
|
If the calibration is not available |
UnsupportedMediaTypeError
|
If the media type is not supported |
Source code in src/vericlient/daspeak/client.py
compare
¶
Compare two sets of data, dispatching on the type of the input model.
Deprecated, and removed in 1.0.0. There are five comparisons behind this one method and the only way to pick between them was to pass one of five classes, so it could not be called at all without importing one. Each has a method of its own now:
| This model | That method |
|---|---|
CompareCredential2AudioInput |
compare_credential_to_audio |
CompareAudio2AudioInput |
compare_audio_to_audio |
CompareCredential2CredentialInput |
compare_credential_to_credential |
CompareAudio2CredentialsInput |
identify_audio |
CompareCredential2CredentialsInput |
identify_credential |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_model
|
CompareInput
|
One of the five comparison inputs |
required |
Returns:
| Type | Description |
|---|---|
CompareCredential2AudioOutput | CompareAudio2AudioOutput | CompareCredential2CredentialOutput | CompareAudio2CredentialsOutput | CompareCredential2CredentialsOutput
|
The response from the service, of the kind matching the input |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/vericlient/daspeak/client.py
compare_credential_to_audio
¶
compare_credential_to_audio(
credential_reference,
audio_to_evaluate,
channel=1,
calibration=DEFAULT_CALIBRATION,
)
Compare a stored credential against a recording.
The everyday verification: enrol once into a credential, then check later recordings against it without keeping the original audio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential_reference
|
str
|
The stored credential |
required |
audio_to_evaluate
|
str | bytes
|
The recording to check, as a path or as bytes |
required |
channel
|
int
|
Which channel to read, when the recording is stereo |
1
|
calibration
|
str
|
The calibration to use, from |
DEFAULT_CALIBRATION
|
Returns:
| Name | Type | Description |
|---|---|---|
CompareCredential2AudioOutput |
CompareCredential2AudioOutput
|
The score, and whether it passes |
Raises:
| Type | Description |
|---|---|
InvalidCredentialError
|
If the credential is not valid |
NetSpeechDurationIsNotEnoughError
|
If the recording holds too little speech |
CalibrationNotAvailableError
|
If the calibration is not available |
Source code in src/vericlient/daspeak/client.py
compare_audio_to_audio
¶
compare_audio_to_audio(
audio_reference,
audio_to_evaluate,
channel_reference=1,
channel_to_evaluate=1,
calibration=DEFAULT_CALIBRATION,
)
Compare two recordings directly, without generating a credential first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio_reference
|
str | bytes
|
The reference recording, as a path or as bytes |
required |
audio_to_evaluate
|
str | bytes
|
The recording to check, as a path or as bytes |
required |
channel_reference
|
int
|
Which channel of the reference to read |
1
|
channel_to_evaluate
|
int
|
Which channel of the recording to check |
1
|
calibration
|
str
|
The calibration to use, from |
DEFAULT_CALIBRATION
|
Returns:
| Name | Type | Description |
|---|---|---|
CompareAudio2AudioOutput |
CompareAudio2AudioOutput
|
The score, and whether it passes |
Raises:
| Type | Description |
|---|---|
NetSpeechDurationIsNotEnoughError
|
If either recording holds too little speech |
SignalNoiseRatioError
|
If either recording is too noisy |
CalibrationNotAvailableError
|
If the calibration is not available |
Source code in src/vericlient/daspeak/client.py
compare_credential_to_credential
¶
compare_credential_to_credential(
credential_reference,
credential_to_evaluate,
calibration=DEFAULT_CALIBRATION,
)
Compare two stored credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential_reference
|
str
|
The reference credential |
required |
credential_to_evaluate
|
str
|
The credential to check against it |
required |
calibration
|
str
|
The calibration to use, from |
DEFAULT_CALIBRATION
|
Returns:
| Name | Type | Description |
|---|---|---|
CompareCredential2CredentialOutput |
CompareCredential2CredentialOutput
|
The score, and whether it passes |
Raises:
| Type | Description |
|---|---|
InvalidCredentialError
|
If either credential is not valid |
CalibrationNotAvailableError
|
If the calibration is not available |
Source code in src/vericlient/daspeak/client.py
identify_audio
¶
identify_audio(
audio_to_evaluate,
credential_list,
channel=1,
calibration=DEFAULT_CALIBRATION,
)
Find which of several credentials a recording belongs to.
One against many, where the comparison methods are one against one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio_to_evaluate
|
str | bytes
|
The recording to identify, as a path or as bytes |
required |
credential_list
|
list[tuple[str, str]]
|
The candidates, as |
required |
channel
|
int
|
Which channel to read, when the recording is stereo |
1
|
calibration
|
str
|
The calibration to use, from |
DEFAULT_CALIBRATION
|
Returns:
| Name | Type | Description |
|---|---|---|
CompareAudio2CredentialsOutput |
CompareAudio2CredentialsOutput
|
A score per candidate |
Raises:
| Type | Description |
|---|---|
InvalidCredentialError
|
If a credential is not valid |
NetSpeechDurationIsNotEnoughError
|
If the recording holds too little speech |
Source code in src/vericlient/daspeak/client.py
identify_credential
¶
identify_credential(
credential_to_evaluate,
credential_list,
calibration=DEFAULT_CALIBRATION,
)
Find which of several credentials another credential belongs to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential_to_evaluate
|
str
|
The credential to identify |
required |
credential_list
|
list[tuple[str, str]]
|
The candidates, as |
required |
calibration
|
str
|
The calibration to use, from |
DEFAULT_CALIBRATION
|
Returns:
| Name | Type | Description |
|---|---|---|
CompareCredential2CredentialsOutput |
CompareCredential2CredentialsOutput
|
A score per candidate |
Raises:
| Type | Description |
|---|---|
InvalidCredentialError
|
If a credential is not valid |
CalibrationNotAvailableError
|
If the calibration is not available |
Source code in src/vericlient/daspeak/client.py
vericlient.daspeak.models
¶
Module to define the models for the Daspeak API.
DEFAULT_CALIBRATION
module-attribute
¶
The calibration the service applies when none is asked for.
DaspeakResponse
¶
Bases: BaseModel
Base class for the Daspeak API responses.
Attributes:
| Name | Type | Description |
|---|---|---|
version |
str
|
The version of the API |
Source code in src/vericlient/daspeak/models.py
ModelsOutput
¶
Bases: DaspeakResponse
Output class for the get models endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
models |
list
|
The available models in the service |
Source code in src/vericlient/daspeak/models.py
BiometricsModelMetadata
¶
Bases: BaseModel
Metadata describing a biometrics model.
Attributes:
| Name | Type | Description |
|---|---|---|
hash |
str
|
The hash that identifies the model |
description |
str
|
The human readable description of the model, such as its release |
Source code in src/vericlient/daspeak/models.py
GetModelMetadataInput
¶
Bases: BaseModel
Input class for the model metadata endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
hash |
str
|
The hash of the biometrics model to describe |
Source code in src/vericlient/daspeak/models.py
GetModelMetadataOutput
¶
Bases: DaspeakResponse
Output class for the model metadata endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
metadata |
BiometricsModelMetadata
|
The metadata of the model |
Source code in src/vericlient/daspeak/models.py
GetModelCalibrationsInput
¶
Bases: BaseModel
Input class for the model calibration endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
hash |
str
|
The hash of the biometrics model to list the calibrations of |
Source code in src/vericlient/daspeak/models.py
GetModelCalibrationsOutput
¶
Bases: DaspeakResponse
Output class for the model calibration endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
calibrations |
list[str]
|
The calibration modes the model supports |
Source code in src/vericlient/daspeak/models.py
GetModelMetadataFromCredentialInput
¶
Bases: BaseModel
Input class for the model metadata from credential endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
credential |
str
|
The credential to read the originating model from |
Source code in src/vericlient/daspeak/models.py
GetModelMetadataFromCredentialOutput
¶
Bases: DaspeakResponse
Output class for the model metadata from credential endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
metadata |
BiometricsModelMetadata
|
The metadata of the model the credential was generated with |
Source code in src/vericlient/daspeak/models.py
GenerateCredentialInput
¶
Bases: BaseModel
Input class for the generate credential endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
audio |
Media
|
The audio to generate the credential with. It can be a path to a file or a bytes object with the audio content |
hash |
str
|
The hash of the biometrics model to use |
channel |
int
|
The |
calibration |
str
|
The calibration to use |
Source code in src/vericlient/daspeak/models.py
ModelMetadata
¶
Bases: BaseModel
Metadata of the model used to generate the credential.
Attributes:
| Name | Type | Description |
|---|---|---|
hash |
str
|
The hash of the model |
mode |
str
|
The mode of the model |
Source code in src/vericlient/daspeak/models.py
GenerateCredentialOutput
¶
Bases: DaspeakResponse
Output class for the generate credential endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
ModelMetadata
|
The model used to generate the credential |
credential |
str
|
The generated credential |
authenticity |
float
|
The authenticity of the audio sample used |
input_audio_duration |
float
|
The duration of the input audio |
net_speech_duration |
float
|
The duration of the speech in the audio |
Source code in src/vericlient/daspeak/models.py
CompareInput
¶
Bases: BaseModel
Base class for the similarity inputs.
Attributes:
| Name | Type | Description |
|---|---|---|
calibration |
str
|
The calibration to use |
Source code in src/vericlient/daspeak/models.py
CompareOutput
¶
Bases: DaspeakResponse
Base class for the similarity outputs.
Attributes:
| Name | Type | Description |
|---|---|---|
score |
float
|
The similarity score between the two inputs |
Source code in src/vericlient/daspeak/models.py
CompareCredential2CredentialInput
¶
Bases: CompareInput
Input class for the similarity credential to credential endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
credential_reference |
str
|
The reference credential |
credential_to_evaluate |
str
|
The credential to evaluate |
calibration |
str
|
The calibration to use |
Source code in src/vericlient/daspeak/models.py
CompareCredential2CredentialOutput
¶
Bases: CompareOutput
Output class for the similarity credential to credential endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
calibration |
str
|
The calibration used |
Source code in src/vericlient/daspeak/models.py
CompareCredential2AudioInput
¶
Bases: CompareInput
Input class for the similarity credential to audio endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
credential_reference |
str
|
The reference credential |
audio_to_evaluate |
Media
|
The audio to evaluate. It can be a path to a file or a bytes object with the audio content |
channel |
int
|
The |
Source code in src/vericlient/daspeak/models.py
CompareCredential2AudioOutput
¶
Bases: CompareOutput
Output class for the similarity credential to audio endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
ModelMetadata
|
The model used to generate the credential |
calibration |
str
|
The calibration used |
authenticity_to_evaluate |
float
|
The authenticity of the audio sample used |
input_audio_duration |
float
|
The duration of the input audio |
net_speech_duration |
float
|
The duration of the speech in the audio |
Source code in src/vericlient/daspeak/models.py
CompareAudio2AudioInput
¶
Bases: CompareInput
Input class for the similarity audio to audio endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
audio_reference |
Media
|
The reference audio. It can be a path to a file or a bytes object with the audio content |
audio_to_evaluate |
Media
|
The audio to evaluate. It can be a path to a file or a bytes object with the audio content |
channel_reference |
int
|
The |
channel_to_evaluate |
int
|
The |
Source code in src/vericlient/daspeak/models.py
CompareAudio2AudioOutput
¶
Bases: CompareOutput
Output class for the similarity audio to audio endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
ModelMetadata
|
The model used to generate the credential |
calibration |
str
|
The calibration used |
authenticity_reference |
float
|
The authenticity of the reference audio sample |
authenticity_to_evaluate |
float
|
The authenticity of the audio to evaluate |
input_audio_duration_reference |
float
|
The duration of the reference audio |
input_audio_duration_to_evaluate |
float
|
The duration of the audio to evaluate |
net_speech_duration_reference |
float
|
The duration of the speech in the reference audio |
net_speech_duration_to_evaluate |
float
|
The duration of the speech in the audio to evaluate |
Source code in src/vericlient/daspeak/models.py
CompareAudio2CredentialsInput
¶
Bases: CompareInput
Input class for the identification audio to credentials endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
audio_to_evaluate |
Media
|
The audio to evaluate against the credential list. It can be a path to a file or a bytes object with the audio content |
credential_list |
list[dict[str, str]]
|
The credentials to compare the audio with. The list contains touples with two strings: the id and the credential |
channel |
int
|
The |
Source code in src/vericlient/daspeak/models.py
validate_and_build_list_format
¶
Turn (id, credential) pairs into the shape the service wants.
Accepts its own output as well, so Model(**dict(model)) round-trips. Without that
a model could not be rebuilt from its own fields, which is exactly what happens when
one method hands its arguments to another.
Source code in src/vericlient/daspeak/models.py
CompareAudio2CredentialsOutput
¶
Bases: DaspeakResponse
Output class for the identification audio to credentials endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
result |
dict
|
The result of the identification, a dictionary with the "id" and the "score" of the best match |
scores |
list[dict]
|
The whole list of scores for each credential. The list contains dictionaries with two keys (and values): "id" and "score" |
calibration |
str
|
The calibration used |
model |
ModelMetadata
|
The model used to generate the credential |
authenticity_to_evaluate |
float
|
The authenticity of the evaluated audio sample |
input_audio_duration_to_evaluate |
float
|
The duration of the evaluated audio |
net_speech_duration_to_evaluate |
float
|
The duration of the speech in the evaluated audio |
Source code in src/vericlient/daspeak/models.py
CompareCredential2CredentialsInput
¶
Bases: CompareInput
Input class for the identification credential to credentials endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
credential_to_evaluate |
str
|
The credential to evaluate against the credential list |
credential_list |
list[dict[str, str]]
|
The credentials to compare the audio with. The list contains touples with two strings: the id and the credential |
Source code in src/vericlient/daspeak/models.py
validate_and_build_list_format
¶
Turn (id, credential) pairs into the shape the service wants.
Accepts its own output as well, so Model(**dict(model)) round-trips. Without that
a model could not be rebuilt from its own fields, which is exactly what happens when
one method hands its arguments to another.
Source code in src/vericlient/daspeak/models.py
CompareCredential2CredentialsOutput
¶
Bases: DaspeakResponse
Output class for the identification credential to credentials endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
result |
dict
|
The result of the identification, a dictionary with the "id" and the "score" of the best match |
scores |
list[dict]
|
The whole list of scores for each credential. The list contains dictionaries with two keys (and values): "id" and "score" |
calibration |
str
|
The calibration used |
Source code in src/vericlient/daspeak/models.py
vericlient.daspeak.exceptions
¶
Module to define the exceptions for the Daspeak API.
DaspeakError
¶
AudioInputError
¶
TooManyAudioChannelsError
¶
Bases: AudioInputError
Exception raised for too many audio channels.
Source code in src/vericlient/daspeak/exceptions.py
UnsupportedSampleRateError
¶
Bases: AudioInputError
Exception raised for unsupported sample rates.
Source code in src/vericlient/daspeak/exceptions.py
AudioDurationTooLongError
¶
Bases: AudioInputError
Exception raised for audio duration too long.
Source code in src/vericlient/daspeak/exceptions.py
UnsupportedAudioCodecError
¶
Bases: AudioInputError
Exception raised for unsupported audio codec.
Source code in src/vericlient/daspeak/exceptions.py
SignalNoiseRatioError
¶
Bases: DaspeakError
Exception raised for errors in the signal noise ratio.
Source code in src/vericlient/daspeak/exceptions.py
NetSpeechDurationIsNotEnoughError
¶
Bases: DaspeakError
Exception raised for errors in the net speech duration.
Source code in src/vericlient/daspeak/exceptions.py
InvalidSpecifiedChannelError
¶
Bases: DaspeakError
Exception raised for invalid specified channel.
Source code in src/vericlient/daspeak/exceptions.py
InsufficientQualityError
¶
Bases: DaspeakError
Exception raised for insufficient quality.
Source code in src/vericlient/daspeak/exceptions.py
CalibrationNotAvailableError
¶
Bases: DaspeakError
Exception raised for calibration not available.
Source code in src/vericlient/daspeak/exceptions.py
ModelNotAvailableError
¶
Bases: DaspeakError
Exception raised when the requested biometrics model does not exist.