Voice fingerprints
Turn a clip of one speaker into an embedding you can compare with other clips.
Overview
A voice fingerprint is an embedding of the speaker in an audio clip.
POST /v1/audio/voices/fingerprint takes one clip and returns its fingerprint.
Compare fingerprints to tell whether two clips have the same speaker. The
request creates no voice.
Create a fingerprint
curl https://api.sprag.ai/v1/audio/voices/fingerprint \
-H "Authorization: Bearer $SPRAG_API_KEY" \
-F model=chorus \
-F [email protected]| Field | Required | Type | Notes |
|---|---|---|---|
model | Yes | string | chorus. |
file | Yes | file | One clip of one speaker. |
The response carries the fingerprint and the request's usage.
{
"object": "audio.voice.fingerprint",
"model": "chorus",
"fingerprint": {
"type": "embedding",
"embedding": [-0.0050048828125, -0.0037841796875, 0.1630859375]
},
"usage": {
"input": {
"audio": { "duration": "5.2" },
"invocations": 1
}
}
}| Field | Notes |
|---|---|
object | audio.voice.fingerprint. |
model | The model as sent in the request. |
fingerprint.type | embedding. |
fingerprint.embedding | The speaker vector, as a list of numbers. Every fingerprint from one model has the same length. The example above is shortened. |
usage.input.audio.duration | The clip's duration in seconds, as a string. |
usage.input.invocations | 1. One request is one fingerprint. |
Compare fingerprints
Compare two fingerprints with cosine similarity. A higher score means the two clips are more likely to have the same speaker. Choose the threshold for a match from clips of speakers you already know.
import math
def cosine(a: list[float], b: list[float]) -> float:
dot = sum(x * y for x, y in zip(a, b))
return dot / (math.sqrt(sum(x * x for x in a)) * math.sqrt(sum(y * y for y in b)))Constraints
- A fingerprint is comparable only with fingerprints from the same model.
- A request takes one clip and returns one fingerprint.
Errors
| Status | Meaning |
|---|---|
400 | Sent when model or file is missing, when file is empty, or when file is not audio the API can decode. Also sent with the error code model_not_supported when the model does not create fingerprints. |
401 | Sent when the API key is missing or not valid. |
Next steps
The rate per fingerprint can be found on the pricing page. For the voices you can speak with, see Voices.