The Expression Measurement API is being sunset.
This guide walks you through using Hume’s Expression Measurement API with the Python SDK. You will submit a batch job to analyze a media file and then connect to the streaming API for real-time predictions.
Get your API key from the Hume AI platform and set it as an environment variable.
The Batch API lets you submit files for processing and retrieve predictions when the job completes. This is best for analyzing recordings, datasets, and other pre-recorded content.
Start a job by specifying the models you want to run and the URLs of the files to process.
You can also upload local files instead of URLs. See the API reference for the local file upload endpoint.
Poll the job status until it reaches COMPLETED or FAILED.
For production use, consider passing a callback_url when submitting the job. Hume will send a POST request to your
URL when the job completes, eliminating the need to poll. The webhook payload includes the job_id, status, and
predictions.
Once the job completes, retrieve and print the predictions.
Predictions are also available as CSV files. Use the Get job artifacts endpoint to download a zip archive containing one CSV per model.
The Streaming API provides real-time predictions over a WebSocket connection. This is best for live audio, video, and interactive applications.
Use the async client to open a streaming connection and send text for analysis.
You can also send audio or video files through the streaming connection.