Background Noise
The background noise metric checks whether your voice agent's speech has a constant hiss, hum or room noise behind it. It compares how loud the agent's speech is with the noise underneath it, and returns the share of agent replies where the speech stands well clear of the noise, between 0 and 1.
Required Arguments
To use the BackgroundNoiseMetric, you'll have to provide a ConversationalTestCase with audio on the agent's turns, or on the test case as a stereo recording of the whole call*.
* Full call audio has to be stereo, with the caller and agent on separate channels, and is only used when no turn has audio. Each agent reply is then heard on the agent's channel, from its first sound until the caller speaks.
Usage
The BackgroundNoiseMetric() can be used for end-to-end evaluation of voice calls, such as ones produced by the ConversationSimulator in voice mode:
from deepeval import evaluate
from deepeval.dataset import ConversationalGolden
from deepeval.metrics import BackgroundNoiseMetric
from deepeval.simulator import ConversationSimulator
from deepeval.voice import ElevenLabsConnector, VoiceConfig
golden = ConversationalGolden(
scenario="The user asks the agent to look up an order by its number.",
expected_outcome="The agent reads back the order status.",
)
simulator = ConversationSimulator(
voice_config=VoiceConfig(
connector=ElevenLabsConnector(agent_id="your-agent-id"),
)
)
test_cases = simulator.simulate([golden])
metric = BackgroundNoiseMetric(threshold=0.8)
evaluate(test_cases=test_cases, metrics=[metric])There are THREE optional parameters specific to the BackgroundNoiseMetric, on top of the common voice metric parameters:
- [Optional]
min_snr_db: an integer for the lowest signal-to-noise ratio (SNR: how far the speech sits above the noise), in dB, a reply may have before it counts as noisy. Must be0or more. Defaulted to18. - [Optional]
eval_mode:"deterministic"or"hybrid". In"hybrid", each noisy reply is double-checked by an audio decision model before it counts. Defaulted to the configured voice eval mode ("deterministic"unless set). - [Optional]
audio_decision_model: the model that does the second check in"hybrid"mode. Defaulted toHumeDecisionModel().
As a standalone
You can also run the BackgroundNoiseMetric on a single test case as a standalone, one-off execution:
metric.measure(test_cases[0])
print(metric.score, metric.reason)
print(metric.score_breakdown)See Events for what score_breakdown contains.
Events
Each noisy reply shows up in score_breakdown as one event. Here is what the example call returns:
{
"eligible_turns": 3,
"turns_with_events": 1,
"events": [
{
"type": "background_noise",
"turn": 3,
"timing_source": "turn_timestamps",
"description": "Background noise was high (SNR 13 dB)",
"estimated_snr_db": 13.3,
"offset_seconds": 0.0,
"duration_seconds": 3.0,
"start_time": 8.5,
"mark": "whole_reply",
}
],
"skipped": [
{
"turn": 5,
"error": "Reply is under 2 seconds, too short to measure its noise.",
}
],
}| Field | What it means |
|---|---|
estimated_snr_db | How far the reply's speech sits above its background noise, in dB |
Each event covers the whole reply, so offset_seconds is 0 and duration_seconds is the clip's length. Replies that are too short, silent or can't be decoded are listed under skipped. Every event also has the fields all voice events share, such as mark and description.
eligible_turns is how many agent replies were counted and turns_with_events how many were noisy. The score is the share that weren't.
How Is It Calculated?
The BackgroundNoiseMetric score is calculated according to the following equation:
Which replies are scored
A reply is skipped when it:
- is under 2 seconds long, since noise is measured in the pauses between words and a short reply rarely has one, or
- has no audible sound at all, which Silent Reply reports instead.
Noise criteria
Speech should sit far above the noise in its pauses. A noisy reply has a raised floor between words.
Each reply is cut into 20 ms frames and measured like this:
| Check | Rule |
|---|---|
| Speech level | The 90th percentile of frames at speech volume (about −41 dBFS or louder) |
| Noise level | The 10th percentile of all frames, leaving out digital silence |
| Noisy | Speech level is less than min_snr_db (18 dB) above the noise level |
If no reply is long enough, the metric is skipped.
Second check
In the hybrid eval mode, each noisy reply is double-checked before it counts. The audio decision model hears the agent's whole reply, from that turn's own clip, or from the reply cut from full call audio when no turn has audio, and is asked:
Is there distracting background noise behind the speaker?
If the model judges "no" more likely than "yes", the reply is dismissed and doesn't count against the score.
Example call
A call where one agent reply has a loud hiss behind it and one is too short to measure.
| Agent turn | Signal-to-noise | Noisy? |
|---|---|---|
| 1 | 45.7 dB | No |
| 3 | 13.3 dB | Yes |
| 5 | Under 2 seconds | Skipped |
| 7 | 45.7 dB | No |
| 3 replies | 1 noisy → 2/3 = 0.67 |
FAQs
How is this different from Speech Intelligibility?
What should I set min_snr_db to?
Does this metric call an LLM or an external speech model?
"hybrid" eval mode, each noisy reply is also checked by an audio decision model, at one paid request per noisy reply.