Voice Verification
Voice verification allows you to register a voice fingerprint and verify incoming voice samples before executing sensitive actions like releasing payments.
Use Case
With the rise of voice cloning and deepfakes, it’s critical to verify that a voice command actually came from the authorized person before:
- Releasing payments
- Authorizing transactions
- Approving access requests
- Executing high-value actions
How It Works
- Register a voice fingerprint (hash of voice embedding)
- Verify incoming voice samples against the registered fingerprint
- Only proceed if verification passes
Setup
1. Generate Voice Fingerprint
First, create a voice embedding using your preferred provider:
# Example with a voice embedding model
from your_voice_model import get_voice_embedding
import hashlib
# Get embedding from voice sample(s)
embedding = get_voice_embedding("voice_sample.wav")
# Hash the embedding for privacy
fingerprint_hash = hashlib.sha256(embedding.tobytes()).hexdigest()
2. Register with Treeship
from treeship_sdk import Treeship
ts = Treeship(api_key='your-key')
# Register the voice fingerprint
ts.register_voice_fingerprint(
agent="payment-agent",
fingerprint_hash=fingerprint_hash,
provider="elevenlabs", # or "resemble", "azure", "custom"
sample_count=3 # Number of samples used
)
3. Verify Before Payment
def process_voice_payment(voice_file, amount, recipient):
# Extract fingerprint from incoming voice
embedding = get_voice_embedding(voice_file)
incoming_hash = hashlib.sha256(embedding.tobytes()).hexdigest()
# Verify with Treeship
result = ts.verify_voice(
agent="payment-agent",
fingerprint_hash=incoming_hash
)
if result["safe_for_payment"]:
# Voice is authentic - proceed with payment
process_payment(amount, recipient)
# Create attestation
ts.attest(
action=f"Released payment of ${amount} to {recipient}",
metadata={"voice_verified": True, "confidence": result["confidence"]}
)
else:
# Voice doesn't match - reject
raise SecurityError("Voice verification failed")
API Reference
Register Voice Fingerprint
curl -X POST https://api.treeship.dev/v1/identity/my-agent/voice-fingerprint \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fingerprint_hash": "sha256-of-voice-embedding",
"provider": "elevenlabs",
"sample_count": 3
}'
Verify Voice
curl -X POST "https://api.treeship.dev/v1/identity/my-agent/verify-voice?fingerprint_hash=sha256-of-incoming-voice"
Response
{
"verified": true,
"agent_slug": "payment-agent",
"confidence": 1.0,
"safe_for_payment": true
}
Supported Providers
| Provider | Description |
|---|
elevenlabs | ElevenLabs voice embeddings |
resemble | Resemble.AI voice prints |
azure | Azure Speaker Recognition |
aws | Amazon Voice ID |
custom | Your own embedding model |
Security Considerations
Voice fingerprints are hashed before storage. Treeship never stores raw voice samples or embeddings.
Best Practices
- Use multiple samples — Register with 3+ voice samples for accuracy
- Re-register periodically — Voice can change over time
- Combine with other factors — Use voice as one factor in multi-factor auth
- Set thresholds — Adjust confidence thresholds based on risk tolerance
Example: Payment Release Flow
from treeship_sdk import Treeship
ts = Treeship(api_key='your-key')
async def handle_voice_payment_request(voice_sample, payment_request):
# 1. Extract voice fingerprint
fingerprint = extract_voice_fingerprint(voice_sample)
# 2. Verify voice authenticity
voice_result = ts.verify_voice(
agent="payment-agent",
fingerprint_hash=fingerprint
)
if not voice_result["safe_for_payment"]:
return {"error": "Voice verification failed", "release": False}
# 3. Process payment
payment_result = await process_payment(payment_request)
# 4. Create verified attestation
attestation = ts.attest(
action=f"Voice-verified payment: ${payment_request.amount}",
metadata={
"voice_verified": True,
"voice_confidence": voice_result["confidence"],
"recipient": payment_request.recipient
},
human_approved=False # Automated via voice
)
return {
"success": True,
"payment_id": payment_result.id,
"verification_url": attestation.url
}
Combining with Human Approval
For high-value transactions, combine voice verification with human approval:
if amount > 10000:
# High value - require both voice AND human approval
result = ts.attest(
action=f"Large payment: ${amount}",
human_approved=True,
human_approver_hash=ts.hash("finance-manager@company.com"),
metadata={"voice_verified": True}
)