Python SDK for RedenLab ML inference service
Project description
RedenLab Extract SDK
Python SDK for RedenLab's ML inference service. Run machine learning models on audio files using RedenLab's proprietary endpoints.
Features
- JWT-based authentication — browser login for humans, env vars for machines
- Simple session + client pattern: upload once, run any model
- Async job management with polling and progress callbacks
- Automatic chunking for long audio files
- Built-in retry logic and error handling
Installation
pip install redenlab-extract
Authentication
The SDK uses JWT tokens issued by AWS Cognito. Two modes are auto-detected:
Human / Interactive (PKCE)
Run once from the terminal:
redenlab login
This opens a browser, authenticates you, and stores tokens in
~/.redenlab-ml/credentials.yaml. The SDK refreshes tokens silently — you
only need to run redenlab login again if your session expires.
Machine / Headless (Client Credentials)
Set environment variables before running your script:
export REDENLAB_CLIENT_ID=your-client-id
export REDENLAB_CLIENT_SECRET=your-client-secret
The SDK detects these and fetches a token automatically. No browser, no disk tokens.
Priority: if both env vars are set, Client Credentials is used regardless of any stored PKCE tokens.
Quick Start
from redenlab_extract import RedenLabSession, intelligibility_client, run_inference
session = RedenLabSession()
client = intelligibility_client(session, model_name="als-intelligibility-v1")
result = run_inference(session, client, "audio.wav")
print(result["result"]["intelligibility_score"])
from redenlab_extract import RedenLabSession, TranscribeClient, run_inference
session = RedenLabSession()
client = TranscribeClient(session, language_code="en-US")
result = run_inference(session, client, "audio.wav")
print(result["transcript"])
Available Models
Intelligibility
from redenlab_extract import intelligibility_client
client = intelligibility_client(session, model_name="als-intelligibility-v1")
# model_name options: "als-intelligibility-v1", "als-intelligibility-v2",
# "ataxia-intelligibility"
Naturalness
from redenlab_extract import naturalness_client
client = naturalness_client(session, model_name="als-naturalness-v1")
# model_name options: "als-naturalness-v1", "als-naturalness-v2",
# "ataxia-naturalness"
Transcription (AWS Transcribe)
from redenlab_extract import TranscribeClient
client = TranscribeClient(
session,
language_code="en-US", # optional, defaults to "en-US"
max_speaker_count=4, # optional, defaults to 10
)
WhisperX
from redenlab_extract import whisperX_client
client = whisperX_client(session, diarize=True, batch_size=16)
Speaker Counter
from redenlab_extract import speaker_counter_client
client = speaker_counter_client(session)
Speaker Diarization
from redenlab_extract import speaker_diarization_client
client = speaker_diarization_client(session)
Sylber Time
from redenlab_extract import sylber_time_client
client = sylber_time_client(session)
Usage Patterns
Level 1 — run_inference() (recommended)
Handles upload, chunking, and inference in one call:
from redenlab_extract import RedenLabSession, intelligibility_client, run_inference
session = RedenLabSession()
client = intelligibility_client(session, model_name="als-intelligibility-v1")
result = run_inference(session, client, "audio.wav")
Long files are chunked automatically and results are aggregated.
Level 2 — Upload → Submit → Poll
Useful for batch processing or when you want to decouple upload from inference:
# Upload
asset = session.upload("audio.wav")
# Submit (with retry for async S3 processing)
job_id = client._submit_with_upload_wait(asset)
# Poll
result = client.poll(job_id, timeout=600)
Level 3 — Batch processing
Submit all jobs first, then poll concurrently:
# Upload and submit all files
assets = [session.upload(f) for f in audio_files]
job_ids = [client._submit_with_upload_wait(asset) for asset in assets]
# Poll each
results = [client.poll(job_id) for job_id in job_ids]
Progress callbacks
def on_progress(status):
print(f"Status: {status['status']}")
result = run_inference(session, client, "audio.wav", progress_callback=on_progress)
Chunked inference (long files)
run_inference() chunks automatically. For manual control:
from redenlab_extract import run_chunked_inference, aggregate_results
chunks = run_chunked_inference(session, client, "long_audio.wav", chunk_duration=50)
result = aggregate_results(chunks, score_key="intelligibility_score")
Backend warmup
SageMaker-backed models (intelligibility, naturalness) may be cold after inactivity:
health = client.health()
if not health["ready"]:
client.warmup() # submits a dummy job to wake the endpoint
Configuration
Base URL
Resolved in priority order:
| Source | How |
|---|---|
| Constructor | RedenLabSession(base_url="https://...") |
| Environment variable | REDENLAB_ML_BASE_URL=https://... |
| Config file | ~/.redenlab-ml/config.yaml → base_url: ... |
| Service discovery | Automatic fallback |
Config file (~/.redenlab-ml/config.yaml)
base_url: https://your-api-gateway-url.amazonaws.com/prod # optional
Credentials file (~/.redenlab-ml/credentials.yaml)
Written automatically by redenlab login. Do not edit manually.
Supported File Types
- WAV (
.wav) - FLAC (
.flac) - MP3 (
.mp3) - OGG (
.ogg) - M4A (
.m4a)
Requirements
- Python 3.10+
requeststenacitypyyaml
Optional (for audio chunking):
soundfilenumpy
Support
- Email: support@redenlab.com
- Website: https://redenlab.com
License
MIT License — see LICENSE for details.
Changelog
See CHANGELOG.md for version history.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file redenlab_extract-1.3.1.tar.gz.
File metadata
- Download URL: redenlab_extract-1.3.1.tar.gz
- Upload date:
- Size: 96.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a86d9558d50d060d4b2cf2ecbb1bc6ba6b40895e9b0bd0e36f425cfb483fa135
|
|
| MD5 |
1708f6bd03ead5310e04562f6681d617
|
|
| BLAKE2b-256 |
390280a16d2ce8ed72e1c3c344dab1da2e214f4dec3f1529040b5524ce3ecc14
|
File details
Details for the file redenlab_extract-1.3.1-py3-none-any.whl.
File metadata
- Download URL: redenlab_extract-1.3.1-py3-none-any.whl
- Upload date:
- Size: 43.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23e7130a224c698bc1e605a2d4080689b7c5e0cbfd4d90a1c42581f37f1c286e
|
|
| MD5 |
8c5c66ebaf4a594be5d675499043b376
|
|
| BLAKE2b-256 |
8e1e38b6a407528833a8f5a5c4bcfae9457beb9f39083741d1580dc280f2fb07
|