# SecureSpeak AI Python SDK
The official Python SDK for SecureSpeak AI — Professional deepfake detection with 99.7% accuracy.
## Installation
```bash
pip install securespeakai-sdk
```
## Quick Start
```python
from securespeak import SecureSpeakClient
# Initialize client with your API key
client = SecureSpeakClient("your-api-key-here")
# Analyze a local audio file
result = client.analyze_file("suspicious_audio.wav")
# Check if it's a deepfake
if result['label'] == 'AI':
print(f"DEEPFAKE DETECTED! Confidence: {result['confidence']:.2f}")
else:
print(f"Authentic audio. Confidence: {result['confidence']:.2f}")
```
## Authentication
The SDK supports two types of authentication:
### 1. API Key Authentication (Required)
```python
from securespeak import SecureSpeakClient
client = SecureSpeakClient("your-api-key-here")
```
### 2. Firebase Authentication (Optional - for billing endpoints)
```python
from securespeak import SecureSpeakClient
client = SecureSpeakClient(
api_key="your-api-key-here",
firebase_token="your-firebase-id-token"
)
```
## Core Analysis Methods
### File Analysis
```python
# Analyze local audio files
result = client.analyze_file("audio.wav")
print(f"Result: {result['label']}, Confidence: {result['confidence']:.2f}")
```
### URL Analysis
```python
# Analyze audio from URLs (YouTube, social media, etc.)
result = client.analyze_url("https://youtube.com/watch?v=example")
print(f"Result: {result['label']}, Confidence: {result['confidence']:.2f}")
```
### Live Analysis
```python
# Real-time analysis with per-second billing
result = client.analyze_live("live_audio.wav")
print(f"Result: {result['label']}, Confidence: {result['confidence']:.2f}")
```
## Billing & Account Management
### Get Account Balance
```python
try:
balance_info = client.get_balance()
print(f"Current balance: ${balance_info['balance']:.2f}")
print(f"Usage: {balance_info['usage']}")
except Exception as e:
print(f"Error: {e}")
```
### Get Billing Configuration
```python
config = client.get_billing_config()
print(f"Pricing: {config['pricing']}")
```
### Create Payment Intent
```python
try:
payment_intent = client.create_payment_intent(amount=50.0)
print(f"Payment intent created: {payment_intent['client_secret']}")
except Exception as e:
print(f"Error: {e}")
```
## API Key Management
### Get All User Keys
```python
keys = client.get_user_keys()
for key in keys:
print(f"Key: {key['name']}, Usage: {key['usage_count']}")
```
### Get Key Statistics
```python
stats = client.get_key_stats("your-key-id")
print(f"Total usage: {stats['usage']['total']}")
print(f"AI detected: {stats['usage']['ai_detected']}")
```
### Get Analysis History
```python
history = client.get_analysis_history("your-key-id", limit=10)
for analysis in history['history']:
print(f"Time: {analysis['timestamp']}, Result: {analysis['label']}")
```
## WebSocket Real-time Analysis
For continuous real-time analysis:
```python
from securespeak import SecureSpeakClient
def on_prediction(result):
print(f"Real-time result: {result['label']}, Confidence: {result['confidence']:.2f}")
client = SecureSpeakClient("your-api-key-here")
ws_client = client.create_websocket_connection(on_prediction)
try:
ws_client.connect()
# Send audio frames
with open("audio_frame.wav", "rb") as f:
audio_data = f.read()
ws_client.send_audio_frame(audio_data)
# Keep connection alive
import time
time.sleep(10)
finally:
ws_client.close()
```
## Debug & Monitoring
### System Health Check
```python
status = client.keep_alive()
print(f"API Status: {status['status']}")
```
### Model Information
```python
model_info = client.get_model_info()
print(f"Model status: {model_info['status']}")
```
### Environment Information
```python
env_info = client.get_environment_info()
print(f"Python version: {env_info['python_version']}")
print(f"TensorFlow version: {env_info['tensorflow_version']}")
```
## Response Format
All analysis methods return a comprehensive JSON response:
```json
{
"label": "AI",
"confidence": 0.95,
"analysis_time_ms": 1200,
"file_info": {
"filename": "audio.wav",
"format": "wav",
"source_type": "uploaded_file",
"size_bytes": 1024000
},
"audio_metadata": {
"duration_sec": 30.5,
"sample_rate": 44100,
"channels": 1
},
"endpoint": "/analyze_file",
"timestamp": "2024-01-01T12:00:00Z"
}
```
## Error Handling
The SDK includes comprehensive error handling:
```python
from securespeak import SecureSpeakClient, SecureSpeakAPIError
client = SecureSpeakClient("your-api-key-here")
try:
result = client.analyze_file("audio.wav")
except SecureSpeakAPIError as e:
print(f"API Error ({e.status_code}): {e.message}")
if e.details:
print(f"Details: {e.details}")
except Exception as e:
print(f"Unexpected error: {e}")
```
## Pricing
- **File Analysis**: $0.018 per file
- **URL Analysis**: $0.025 per URL
- **Live Analysis**: $0.032 per second
*Enterprise customers may have custom pricing. Check your billing configuration.*
## Requirements
- Python 3.7 or higher
- Valid SecureSpeak AI API key
- Optional: Firebase authentication for billing endpoints
## Dependencies
- `requests>=2.25.0`
- `websocket-client>=1.2.0`
- `typing-extensions>=4.0.0`
## Advanced Usage
### Batch Processing
```python
import os
from securespeak import SecureSpeakClient
client = SecureSpeakClient("your-api-key-here")
# Process multiple files
audio_files = ["file1.wav", "file2.wav", "file3.wav"]
results = []
for file_path in audio_files:
try:
result = client.analyze_file(file_path)
results.append({
'file': file_path,
'label': result['label'],
'confidence': result['confidence']
})
except Exception as e:
print(f"Error processing {file_path}: {e}")
# Print results
for result in results:
print(f"{result['file']}: {result['label']} ({result['confidence']:.2f})")
```
### Custom Error Handling
```python
from securespeak import SecureSpeakClient, SecureSpeakAPIError
client = SecureSpeakClient("your-api-key-here")
try:
result = client.analyze_file("audio.wav")
except SecureSpeakAPIError as e:
if e.status_code == 402: # Payment Required
print("Insufficient balance!")
print(f"Required: ${e.details.get('required_amount', 0):.3f}")
print(f"Available: ${e.details.get('current_balance', 0):.3f}")
elif e.status_code == 403:
print("Invalid API key!")
else:
print(f"API Error: {e.message}")
```
## Documentation
For complete documentation, examples, pricing, and API reference, visit: https://securespeakai.com/docs
## Support
- Website: https://securespeakai.com
- Dashboard: https://securespeakai.com/dashboard
- Support: https://securespeakai.com/support
## License
MIT License
Raw data
{
"_id": null,
"home_page": "https://securespeakai.com",
"name": "securespeakai-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "deepfake detection, audio analysis, AI, machine learning, api, sdk",
"author": "SecureSpeakAI",
"author_email": "nsharma@securespeakai.com",
"download_url": "https://files.pythonhosted.org/packages/00/8d/cd9bd16658e8de62ebe1416421fc62ef44bfd90b52a9f13a8f9579014961/securespeakai-sdk-1.0.0.tar.gz",
"platform": null,
"description": "# SecureSpeak AI Python SDK\n\nThe official Python SDK for SecureSpeak AI \u2014 Professional deepfake detection with 99.7% accuracy.\n\n## Installation\n\n```bash\npip install securespeakai-sdk\n```\n\n## Quick Start\n\n```python\nfrom securespeak import SecureSpeakClient\n\n# Initialize client with your API key\nclient = SecureSpeakClient(\"your-api-key-here\")\n\n# Analyze a local audio file\nresult = client.analyze_file(\"suspicious_audio.wav\")\n\n# Check if it's a deepfake\nif result['label'] == 'AI':\n print(f\"DEEPFAKE DETECTED! Confidence: {result['confidence']:.2f}\")\nelse:\n print(f\"Authentic audio. Confidence: {result['confidence']:.2f}\")\n```\n\n## Authentication\n\nThe SDK supports two types of authentication:\n\n### 1. API Key Authentication (Required)\n```python\nfrom securespeak import SecureSpeakClient\n\nclient = SecureSpeakClient(\"your-api-key-here\")\n```\n\n### 2. Firebase Authentication (Optional - for billing endpoints)\n```python\nfrom securespeak import SecureSpeakClient\n\nclient = SecureSpeakClient(\n api_key=\"your-api-key-here\",\n firebase_token=\"your-firebase-id-token\"\n)\n```\n\n## Core Analysis Methods\n\n### File Analysis\n```python\n# Analyze local audio files\nresult = client.analyze_file(\"audio.wav\")\nprint(f\"Result: {result['label']}, Confidence: {result['confidence']:.2f}\")\n```\n\n### URL Analysis\n```python\n# Analyze audio from URLs (YouTube, social media, etc.)\nresult = client.analyze_url(\"https://youtube.com/watch?v=example\")\nprint(f\"Result: {result['label']}, Confidence: {result['confidence']:.2f}\")\n```\n\n### Live Analysis\n```python\n# Real-time analysis with per-second billing\nresult = client.analyze_live(\"live_audio.wav\")\nprint(f\"Result: {result['label']}, Confidence: {result['confidence']:.2f}\")\n```\n\n## Billing & Account Management\n\n### Get Account Balance\n```python\ntry:\n balance_info = client.get_balance()\n print(f\"Current balance: ${balance_info['balance']:.2f}\")\n print(f\"Usage: {balance_info['usage']}\")\nexcept Exception as e:\n print(f\"Error: {e}\")\n```\n\n### Get Billing Configuration\n```python\nconfig = client.get_billing_config()\nprint(f\"Pricing: {config['pricing']}\")\n```\n\n### Create Payment Intent\n```python\ntry:\n payment_intent = client.create_payment_intent(amount=50.0)\n print(f\"Payment intent created: {payment_intent['client_secret']}\")\nexcept Exception as e:\n print(f\"Error: {e}\")\n```\n\n## API Key Management\n\n### Get All User Keys\n```python\nkeys = client.get_user_keys()\nfor key in keys:\n print(f\"Key: {key['name']}, Usage: {key['usage_count']}\")\n```\n\n### Get Key Statistics\n```python\nstats = client.get_key_stats(\"your-key-id\")\nprint(f\"Total usage: {stats['usage']['total']}\")\nprint(f\"AI detected: {stats['usage']['ai_detected']}\")\n```\n\n### Get Analysis History\n```python\nhistory = client.get_analysis_history(\"your-key-id\", limit=10)\nfor analysis in history['history']:\n print(f\"Time: {analysis['timestamp']}, Result: {analysis['label']}\")\n```\n\n## WebSocket Real-time Analysis\n\nFor continuous real-time analysis:\n\n```python\nfrom securespeak import SecureSpeakClient\n\ndef on_prediction(result):\n print(f\"Real-time result: {result['label']}, Confidence: {result['confidence']:.2f}\")\n\nclient = SecureSpeakClient(\"your-api-key-here\")\nws_client = client.create_websocket_connection(on_prediction)\n\ntry:\n ws_client.connect()\n \n # Send audio frames\n with open(\"audio_frame.wav\", \"rb\") as f:\n audio_data = f.read()\n ws_client.send_audio_frame(audio_data)\n \n # Keep connection alive\n import time\n time.sleep(10)\n \nfinally:\n ws_client.close()\n```\n\n## Debug & Monitoring\n\n### System Health Check\n```python\nstatus = client.keep_alive()\nprint(f\"API Status: {status['status']}\")\n```\n\n### Model Information\n```python\nmodel_info = client.get_model_info()\nprint(f\"Model status: {model_info['status']}\")\n```\n\n### Environment Information\n```python\nenv_info = client.get_environment_info()\nprint(f\"Python version: {env_info['python_version']}\")\nprint(f\"TensorFlow version: {env_info['tensorflow_version']}\")\n```\n\n## Response Format\n\nAll analysis methods return a comprehensive JSON response:\n\n```json\n{\n \"label\": \"AI\",\n \"confidence\": 0.95,\n \"analysis_time_ms\": 1200,\n \"file_info\": {\n \"filename\": \"audio.wav\",\n \"format\": \"wav\",\n \"source_type\": \"uploaded_file\",\n \"size_bytes\": 1024000\n },\n \"audio_metadata\": {\n \"duration_sec\": 30.5,\n \"sample_rate\": 44100,\n \"channels\": 1\n },\n \"endpoint\": \"/analyze_file\",\n \"timestamp\": \"2024-01-01T12:00:00Z\"\n}\n```\n\n## Error Handling\n\nThe SDK includes comprehensive error handling:\n\n```python\nfrom securespeak import SecureSpeakClient, SecureSpeakAPIError\n\nclient = SecureSpeakClient(\"your-api-key-here\")\n\ntry:\n result = client.analyze_file(\"audio.wav\")\nexcept SecureSpeakAPIError as e:\n print(f\"API Error ({e.status_code}): {e.message}\")\n if e.details:\n print(f\"Details: {e.details}\")\nexcept Exception as e:\n print(f\"Unexpected error: {e}\")\n```\n\n## Pricing\n\n- **File Analysis**: $0.018 per file\n- **URL Analysis**: $0.025 per URL\n- **Live Analysis**: $0.032 per second\n\n*Enterprise customers may have custom pricing. Check your billing configuration.*\n\n## Requirements\n\n- Python 3.7 or higher\n- Valid SecureSpeak AI API key\n- Optional: Firebase authentication for billing endpoints\n\n## Dependencies\n\n- `requests>=2.25.0`\n- `websocket-client>=1.2.0`\n- `typing-extensions>=4.0.0`\n\n## Advanced Usage\n\n### Batch Processing\n```python\nimport os\nfrom securespeak import SecureSpeakClient\n\nclient = SecureSpeakClient(\"your-api-key-here\")\n\n# Process multiple files\naudio_files = [\"file1.wav\", \"file2.wav\", \"file3.wav\"]\nresults = []\n\nfor file_path in audio_files:\n try:\n result = client.analyze_file(file_path)\n results.append({\n 'file': file_path,\n 'label': result['label'],\n 'confidence': result['confidence']\n })\n except Exception as e:\n print(f\"Error processing {file_path}: {e}\")\n\n# Print results\nfor result in results:\n print(f\"{result['file']}: {result['label']} ({result['confidence']:.2f})\")\n```\n\n### Custom Error Handling\n```python\nfrom securespeak import SecureSpeakClient, SecureSpeakAPIError\n\nclient = SecureSpeakClient(\"your-api-key-here\")\n\ntry:\n result = client.analyze_file(\"audio.wav\")\nexcept SecureSpeakAPIError as e:\n if e.status_code == 402: # Payment Required\n print(\"Insufficient balance!\")\n print(f\"Required: ${e.details.get('required_amount', 0):.3f}\")\n print(f\"Available: ${e.details.get('current_balance', 0):.3f}\")\n elif e.status_code == 403:\n print(\"Invalid API key!\")\n else:\n print(f\"API Error: {e.message}\")\n```\n\n## Documentation\n\nFor complete documentation, examples, pricing, and API reference, visit: https://securespeakai.com/docs\n\n## Support\n\n- Website: https://securespeakai.com\n- Dashboard: https://securespeakai.com/dashboard\n- Support: https://securespeakai.com/support\n\n## License\n\nMIT License\n",
"bugtrack_url": null,
"license": null,
"summary": "SecureSpeakAI Python SDK for deepfake detection with comprehensive API support",
"version": "1.0.0",
"project_urls": {
"Documentation": "https://securespeakai.com/docs",
"Homepage": "https://securespeakai.com",
"Support": "https://securespeakai.com/support"
},
"split_keywords": [
"deepfake detection",
" audio analysis",
" ai",
" machine learning",
" api",
" sdk"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0f76b513357d34aff3c538f23e65f963e738e67de7405846ca321a2c27443d47",
"md5": "87af16e54cf92348951d720d32701109",
"sha256": "20964f1b33189b6924b431d0bcb68165c76166fc53860c248cf93a5fb2ab8221"
},
"downloads": -1,
"filename": "securespeakai_sdk-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "87af16e54cf92348951d720d32701109",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7533,
"upload_time": "2025-07-15T12:44:36",
"upload_time_iso_8601": "2025-07-15T12:44:36.710991Z",
"url": "https://files.pythonhosted.org/packages/0f/76/b513357d34aff3c538f23e65f963e738e67de7405846ca321a2c27443d47/securespeakai_sdk-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "008dcd9bd16658e8de62ebe1416421fc62ef44bfd90b52a9f13a8f9579014961",
"md5": "34f0dbf71c19d089e29052a2412c84c6",
"sha256": "f089427a5aa73344f406f1278b6d58682c052123e90fa717e1ea19250ebe3a34"
},
"downloads": -1,
"filename": "securespeakai-sdk-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "34f0dbf71c19d089e29052a2412c84c6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 7643,
"upload_time": "2025-07-15T12:44:38",
"upload_time_iso_8601": "2025-07-15T12:44:38.769185Z",
"url": "https://files.pythonhosted.org/packages/00/8d/cd9bd16658e8de62ebe1416421fc62ef44bfd90b52a9f13a8f9579014961/securespeakai-sdk-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-15 12:44:38",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "securespeakai-sdk"
}