Audio Decisions in LiveKit
Run a LiveKit agent that sends the user’s audio to Hume Audio Decisions with hume.DecisionModel each time the user stops speaking, and puts the answers at the head of the user’s message before the LLM replies. Clone this example to follow along, or fork it as a starting point.
By the end you will have the agent running in your terminal, and you will know how the agent keeps the user’s audio, when it cuts and sends each clip, how the answers reach the LLM, and how to log the user message the LLM receives.
Prerequisites
- Python 3.10 to 3.14, and Git.
- A microphone, and headphones so the agent doesn’t hear its own voice.
- An API key with Hume Audio Decisions access, from the API keys page of the Hume Platform. Request access on the Decisions API page. See Authentication.
- A LiveKit Cloud project. The agent’s speech-to-text, LLM, and text-to-speech run through LiveKit Inference, which uses the project’s API key.
- The LiveKit CLI, which runs the agent in console mode: on your machine, with your microphone and speakers, without joining a LiveKit room. Install it with
brew install livekit-clion macOS, or as in Install the CLI on Linux and Windows.
Run the example
Clone the repository and install its dependencies. If you use uv, it needs version 0.13.6 or later and installs the Python version in .python-version for you. If you use pip, first check that python3 --version reports 3.10 to 3.14.
uv
pip
Copy the example environment file.
Set your Hume API key in .env.local, and set the three LiveKit values from your project’s settings in LiveKit Cloud. A value exported in your shell takes precedence over the file.
Start the agent, which introduces itself and then listens. Press q to stop it.
Speak, then pause. When your turn ends, the agent logs the user message as the LLM receives it: the reading, which holds the answers, then your words. The reading has one signal per decision, named by the decision’s key and followed by its answer: a probability’s value, a choice’s two likeliest options with their probabilities, and a score’s position on its levels. With the example’s three decisions, frustration, speakers, and intelligibility, a line looks like this one, shown without the log prefix.
When a reading is missing or unexpected, check these causes.
(no reading)on a turn means that turn has no answers. Either Hume Audio Decisions didn’t answer within 2 seconds of you stopping, which logs a warning, or the request failed, which logs an error, or it answered none of the decisions, which logs a warning for each.401in that error means the Hume API key is wrong, and403means your organization lacks access to Hume Audio Decisions. The agent keeps running without readings until you fix the key.(no reading)with nothing logged means the turn holds no new speech. Part of your transcript arrived after LiveKit ended the turn, and became a turn of its own.- Most questions need at least 5 seconds of audio. A short reply such as “Yes.” is still sent, since each clip starts half a second before you speak, but its answers are less reliable. See How it sends audio.
How it works
agent.py is the voice agent, and audio_decisions.py holds the AudioDecisions class, which cuts each clip, sends it with hume.DecisionModel, and returns the reading. Each step below links the section of the LiveKit integration guide that explains its pieces.
Adapt it to your agent
- Add it to an existing agent. Follow Install and then Add it to a voice agent in the LiveKit integration guide. The two sections cover what this example sets up: the plugin,
audio_decisions.py, and the changes inAssistantandentrypoint. - Change the decisions. Edit or add decisions in
DECISIONS. See Map LiveKit decisions to primitives and Writing questions. - Describe each decision to the LLM. Give each decision in
DECISIONSa paragraph inINSTRUCTIONSthat says what its value means, as the example does. - Set your own thresholds. The thresholds in
INSTRUCTIONSare the example’s. Set yours from your own calls, as in Setting thresholds, once your decisions and their order are final, since adding, removing, or reordering decisions can change the other answers. - Change the clip length or the wait limit. Pass
clip_secondsorwait_limittoAudioDecisions. See Choose which audio to send and Set the wait limit in code. - Use other models. Any LiveKit Inference model, or a LiveKit plugin for a provider you have an account with, can replace the models in
entrypoint. - Act on answers outside the LLM.
_askhas every answer inresponse.resultsbefore it formats the reading. Act on them there in your backend, such as alerting a supervisor. - Serve users in LiveKit rooms. Console mode serves only your own machine. To reach users in a room, run the agent in one of LiveKit’s other startup modes.