Python quickstart
Ask questions about a recording from Python. The script below asks one question of each primitive about the same audio and prints every answer.
Prerequisites
- Python 3.10 or later.
- An API key from the API keys page of the Hume Platform. See Authentication.
- A recording of speech 5 seconds to 5 minutes long, in MP3 or WAV.
Install
Create a project and install the SDK in it. To add the SDK to an existing project, run only the last command.
uv
pip
Set your API key
The client reads the key from the HUME_API_KEY environment variable and sends it in the X-Hume-Api-Key header of every request.
To pass the key explicitly instead, construct the client with DecisionsClient(api_key="...").
Ask questions about a recording
Run
uv
pip
Each probability estimates the share of human raters who would give that answer, so a noul answer near 0.5 means raters would split on the audio, not that the model is unsure. Ask the same questions in the same order when you compare recordings, since an answer can change when other questions are added, removed or reordered.
Audio helpers
create converts a WAV file to 16 kHz mono before sending it, because the model hears audio as one channel at 16 kHz. The converted file is smaller, so a WAV file over the size limit of 25,000,000 bytes can still fit in a request. Pass downmix_strategy="first_channel" to keep only the first channel, such as to judge one speaker of a call apart from the other, or downmix_strategy=None to send the file as it is. MP3 files are always sent as they are. See Preparing audio in the SDK README.
A request takes up to 5 minutes of audio. To send a longer recording, create_chunked cuts it into chunks of up to max_chunk_ms and sends each chunk in its own request.
The model answers each chunk on its own, and nothing combines the answers across chunks. A span’s times count from the start of its chunk, so the script adds the chunk’s start_ms to place each span in the recording. Most failed requests stop the job, and the chunks after one are not sent; result.resume_ms says where to continue. See Long recordings in the SDK README for choosing a chunk length, where the cuts fall and resuming.