A client library for content security detection
Project description
Framewise SecureLine
Framewise SecureLine is a Python library for analyzing text and audio for security concerns. The library supports text-based detection and audio chunk predictions, offering flexibility for content security use cases.
Features
- Text Detection: Analyze text for security concerns, such as banned topics, PII, or profanity.
- Audio Chunk Analysis: Process audio data in chunks for classification and security predictions.
- Custom Filters: Easily configure filters for denied topics, PII information, and word lists.
- Extensibility: Supports structured outputs for easy integration with your workflows.
- Robust Error Handling: Handles API errors, validation errors, and request timeouts gracefully.
Installation
Framewise SecureLine is available for installation using Poetry or pip.
Install using Poetry
poetry add framewise-secureline
Install using pip
pip install framewise-secureline
Getting Started
Initialization
To use Framewise SecureLine, you need an API key. Initialize the SecureLine
client as shown below:
from framewise_secureline import SecureLine
# Initialize the client
client = SecureLine(
api_key="your-api-key",
denied_topics="medical diagnoses, competitors",
ppi_information="SSN, Medical Records",
word_filters="profanity",
)
Text Detection
Analyze a piece of text for security concerns.
result = client.detect("Sample text for analysis.")
# Access raw response
print(result)
Audio Chunk Analysis
Analyze an audio chunk for predictions. The library accepts a single chunk of type AudioSegment
.
from pydub import AudioSegment
# Load an audio file and extract a chunk
audio = AudioSegment.from_file("/path/to/audio.mpga").set_frame_rate(16000).set_channels(1)
chunk = audio[:100] # Extract first 100ms
# Analyze the chunk
result = client.analyze_audio_chunk(chunk)
# Access predictions
for prediction in result.predictions:
print(f"Label: {prediction.label}, Score: {prediction.score}")
print(f"Latency: {result.latency}, Device: {result.device}")
Advanced Usage
Custom Filters
You can update the filters dynamically using the update_filters
method:
client.update_filters(
denied_topics="new denied topics",
ppi_information="new PII types",
word_filters="new word list",
)
Handling Multiple Audio Chunks
While SecureLine processes one audio chunk at a time, you can handle multiple chunks by iterating over the audio file:
chunks = [audio[i:i+100] for i in range(0, len(audio), 100)] # Split into 100ms chunks
for i, chunk in enumerate(chunks):
result = client.analyze_audio_chunk(chunk)
print(f"Chunk {i}:")
for prediction in result.predictions:
print(f" Label: {prediction.label}, Score: {prediction.score}")
Error Handling
Framewise SecureLine provides robust error handling for common scenarios:
- ValidationError: Raised for invalid inputs (e.g., empty text, incorrect audio format).
- APIError: Raised for server-side errors during API calls.
- TimeoutError: Raised when an API call exceeds the timeout.
Example
from framewise_secureline.exceptions import ValidationError, APIError, TimeoutError
try:
result = client.detect("text to analyze")
except ValidationError as e:
print(f"Validation failed: {e}")
except APIError as e:
print(f"API error: {e}")
except TimeoutError as e:
print(f"Request timed out: {e}")
Testing
The library includes a comprehensive suite of tests.
Run Tests
poetry run pytest
Coverage Report
poetry run pytest --cov=framewise_secureline
Support
For any issues or feature requests, please contact:
Email: sigireddybalasai@gmail.com
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file framewise_secureline-0.1.3.tar.gz
.
File metadata
- Download URL: framewise_secureline-0.1.3.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-1017-gcp
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 425c3fc7a4ff83cec743baf8b2e55ca2df38b8435fbc419de49929da578cd1ed |
|
MD5 | 67cb98ef0a78c7d3f214b2c0b311b27a |
|
BLAKE2b-256 | 80b9b43e51e94a9126c1c00a8bf31b2296e680d5ae748f6c9d5d11be7628f859 |
File details
Details for the file framewise_secureline-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: framewise_secureline-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-1017-gcp
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c157bc40081112daec6f54ca1cbb8c2bdd1a014ae8b50bf48005df8e534a903f |
|
MD5 | 5fbabb052213759f3ea13632182f7380 |
|
BLAKE2b-256 | 1207c968befae947961dcefdf8204be0eba1c773ca623a9e869c570d02b805aa |