Skip to main content

Overview

HumeAudioClassifier answers classifier questions about a clip of audio through Hume’s Audio Decisions API. Hume hears the clip, and answers most questions best with 5 seconds or more of it. It reads the state as the clip’s context, such as who is speaking and what they said. All the questions about one clip go to Hume in one request. Its probabilities estimate the share of human raters who would give each answer. A HumeAudioClassifier asks through a HumeAudioDecisionsClient, which holds the HTTP/2 connection, adds the auth header, retries when Hume is busy, and counts tokens. Build the classifier with an API key to give it a client of its own, or pass a HumeAudioDecisionsClient to share one connection between several classifiers.

Expressive Conversation

A voice bot that reads how the user sounds with Hume and adapts its replies.

Installation

Prerequisites

A Hume API key, usually set as an environment variable:

Configuration

HumeAudioClassifier

str | None
default:"None"
Hume API key, when the classifier should have a client of its own. One of api_key and client is required.
HumeAudioDecisionsClient | None
default:"None"
A client to share with other classifiers. One of api_key and client is required.
str
default:"https://api.cloud.hume.ai"
Where a client of its own sends its questions.
float
default:"10.0"
Seconds a client of its own waits for an answer before raising ClassifierError.
str | None
default:"None"
Name of the classifier, as it appears in logs and metrics.

HumeAudioDecisionsClient

str
required
Hume API key.
str
default:"https://api.cloud.hume.ai"
Where the API is served.
float
default:"10.0"
Seconds to wait for a reply before raising ClassifierError.
int
default:"2"
How many times to retry a request Hume couldn’t answer because it was busy (HTTP 429, 500 or 503).

Usage

Basic Usage

Every call needs exactly one clip in inputs. A call without one raises ClassifierError.

Reading How the User Sounded

Give the classifier, with its questions, to a PerceptionSource of a PerceptionReader, which cuts a clip of the user’s speech each time they stop speaking and adds the answers to the transcription’s perception.

Sharing a Client

Several classifiers can share one HumeAudioDecisionsClient, and with it one connection pool and one token count:
A client the classifier created is closed in the classifier’s cleanup(). A shared client is left open, so close it yourself with await client.close() when every classifier using it is done.

Opening the Connection Early

setup() opens the connection to Hume ahead of the first question. Components that own a classifier, such as PerceptionReader, call it for you. If the connection cannot be opened at setup, a warning is logged and the first question opens it instead.

HumeAudioClassifier Properties

HumeAudioDecisionsClient Reference

Properties

Methods

connect

Opens the connection to Hume with a lightweight request that also checks the key. It counts toward the rate limit like any request. It connects once: a client shared by several classifiers is connected by each of them, and only the first call sends anything. Raises ClassifierError if Hume could not be reached or refused the request.

close

Closes the connection pool.

Metrics

After every call, a HumeAudioClassifier reports the time it took as ProcessingMetricsData and the input tokens used as LLMUsageMetricsData through its on_metrics event.

Notes

  • Context: the state is sent to Hume as the clip’s context, as text or as JSON for structured state. Hume reads at most 1000 characters of it, so a longer state keeps its last 1000 characters. The limit is available as HUME_MAX_CONTEXT in pipecat.classifiers.hume.audio_decisions.classifier.
  • Audio: a call takes exactly one clip in inputs; any other number raises ClassifierError. Clips are sent as 16 kHz mono WAV, which is how the model hears them.
  • Images: HumeAudioClassifier cannot see images. Passing some raises ClassifierError.
  • Errors: a rejected request, a busy Hume after every retry, an unreachable server, or a reply missing an answer all raise ClassifierError.