Audio Decisions in Pipecat
Run a Pipecat bot that classifies the user’s speech with HumeAudioClassifier and attaches the Audio Decisions answers to each transcription before it reaches the LLM. Clone this example to follow along, or fork it as a starting point.
By the end you will have the bot running locally, and you will know how the perception source is configured, where PerceptionReader sits in the pipeline, how expressive conversation passes the answers to the LLM, and how to log the user message the LLM receives.
Prerequisites
- macOS 14 or later on Apple silicon, or Linux on x86-64 or ARM64 with glibc 2.28 or later.
- Python 3.11 to 3.14, and Git.
- PortAudio, which PyAudio needs to reach your microphone and speakers. PyAudio builds from source, so install PortAudio before the dependencies:
brew install portaudioon macOS. Debian and Ubuntu also need a C compiler, the Python headers, and thevenvmodule:sudo apt-get install build-essential portaudio19-dev python3-dev python3-venv. - A microphone, and headphones.
LocalAudioTransporthas no echo cancellation, so without headphones the microphone picks up the bot’s speech as user speech. - An API key from the API keys page of the Hume Platform. Your organization needs access to Audio Decisions, which you can request through the contact form.
- An OpenAI API key. The bot uses OpenAI for speech-to-text, the LLM, and text-to-speech.
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.11 to 3.14.
uv
pip
Copy the example environment file.
Set both API keys in .env. A key exported in your shell takes precedence over the file. The bot stops at startup when HUME_API_KEY is empty or unset, and stops on its first OpenAI request when OPENAI_API_KEY is empty or wrong.
Start the bot, and on macOS allow your terminal app to use the microphone when asked. The bot introduces itself, then listens. Press Ctrl+C to stop it.
uv
pip
Speak, then pause. When the user turn ends, the bot logs the user message as the LLM receives it: the reading, which holds the answers Pipecat attached to the turn, then the transcription. The reading has one signal per question, named by the question’s key and followed by its answer: a yes or no question’s probability, a choice question’s two likeliest options with their probabilities, and a score question’s position on its scale. With the example’s three questions, frustration, speakers, and intelligibility, the lines look like these, shown without loguru’s prefix.
When a reading is missing or unexpected, check these causes.
(no reading)on some turns means those turns have no signals. Either the answers missed the 2-secondtimeout, which logs a warning, or the request failed, which logs an error.HTTP 401in that error means the Hume API key is wrong, andHTTP 403means your organization lacks access to Audio Decisions.(no reading)on every turn, with no warning or error, means expressive conversation is off or the user aggregator has novad_analyzer.- Most questions need at least 5 seconds of audio, and a short user turn right after the bot’s turn is sent with less. See How it sends audio.
How it works
bot.py starts from Pipecat’s local voice agent example, swaps in OpenAI speech-to-text and text-to-speech, and adds the Hume pieces. Each step below links the section of the Pipecat integration guide that explains its pieces.
Adapt it to your agent
- Add it to an existing bot. Install
pipecat-aiwith thehumeextra and setHUME_API_KEY. Copy thePerceptionSourceandPerceptionReader, and placereaderbetween your speech-to-text service and your user aggregator. Give the user aggregator avad_analyzerif it has none, and setenable_expressive_conversation=TrueinPipelineParams, with anExpressionPolicyfor anyguidance. - Change the questions. Edit or add questions in
questions, each with adescriptionfor the LLM. Each key must be one word with none of=,[](), or the bot stops at startup. When the LLM should act on a signal, add a line for it to theguidanceof theExpressionPolicy. See Map Pipecat questions to primitives and Writing questions. - Set your own thresholds. The thresholds in the
guidancelines are the example’s. Set yours from your own calls, as in Setting thresholds, once your questions and their order are final, since adding, removing, or reordering questions can change the other answers. Pipecat’s instructions tell the LLM that “a reading below 0.5 is a guess: don’t act on it”, so a threshold below 0.5 conflicts with them. - Use other services. Any Pipecat speech-to-text, LLM, or text-to-speech service can replace the OpenAI ones. With a text-to-speech service that performs expression tags, the
ExpressionPolicycan also choose how replies are spoken; see Turn on expressive conversation. - Act on answers outside the LLM. Every answer is also broadcast in a
PerceptionFrameas soon as it arrives, including answers that miss the wait limit. A processor placed after the reader can act on them in your backend, such as alerting a supervisor; see Use answers without waiting for the turn. - Use another transport.
LocalAudioTransportserves only your own machine. To reach users over WebRTC or a phone line, replace it with another Pipecat transport. The reader takesInputAudioRawFramefrom any input transport, andHumeAudioClassifierresamples that audio to 16 kHz, so the rest of the pipeline stays as it is.