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 ininputs. A call without one raises ClassifierError.
Reading How the User Sounded
Give the classifier, with its questions, to aPerceptionSource 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 oneHumeAudioDecisionsClient, and with it one connection pool and one token count:
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
ClassifierError if Hume could not be reached or refused the request.
close
Metrics
After every call, aHumeAudioClassifier 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_CONTEXTinpipecat.classifiers.hume.audio_decisions.classifier. - Audio: a call takes exactly one clip in
inputs; any other number raisesClassifierError. Clips are sent as 16 kHz mono WAV, which is how the model hears them. - Images:
HumeAudioClassifiercannot see images. Passing some raisesClassifierError. - Errors: a rejected request, a busy Hume after every retry, an unreachable server, or a reply missing an answer all raise
ClassifierError.