📍 Join the 1st DeepEval meetup in SF, this Friday 5pm PT. RSVP on Luma →
💥 Introducing JevEval: Jev-as-a-Judge for LLM evaluation. Read the post →
Voice AgentsAudio Defects

Audio Clipping

Beta
Multi-turn
Referenceless
Chatbot
Voice

The audio clipping metric checks whether your voice agent's audio is distorted from being too loud, so the voice turns crackly and harsh on loud syllables. It returns the share of agent replies with no clipping, between 0 and 1.

0.0s / 4.3s

Required Arguments

To use the AudioClippingMetric, 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*.

With per-turn audio, an Audio.start_time on each clip is optional, and only used to place events on the call's clock.

* 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 AudioClippingMetric() 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 AudioClippingMetric
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 = AudioClippingMetric(threshold=0.8)
evaluate(test_cases=test_cases, metrics=[metric])

The AudioClippingMetric has no optional parameters of its own. It takes only the common voice metric parameters.

As a standalone

You can also run the AudioClippingMetric 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 clipped reply shows up in score_breakdown as one event. Here is what the example call returns:

{
    "eligible_turns": 4,
    "turns_with_events": 1,
    "events": [
        {
            "type": "clipping",
            "turn": 5,
            "role": "assistant",
            "offset_seconds": 0.048,
            "duration_seconds": 1.657,
            "start_time": 12.548,
            "mark": "range",
            "timing_source": "turn_timestamps",
            "description": "Audio was clipped",
            "position": "start",
            "fraction": 0.0836,
        }
    ],
    "skipped": [],
}
FieldWhat it means
offset_secondsWhere the first clipped sample is, in seconds from the start of the clip
duration_secondsFrom the first clipped sample to the last
fractionThe share of the clip's samples that were clipped
positionWhether the clipped stretch starts near the start, middle or end of the clip

Clips that 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 clipped. The score is the share that weren't.

How Is It Calculated?

The AudioClippingMetric score is calculated according to the following equation:

Audio Clipping=Number of Agent Replies Without ClippingTotal Number of Agent Replies\text{Audio Clipping} = \frac{\text{Number of Agent Replies Without Clipping}}{\text{Total Number of Agent Replies}}

Clipping criteria

Audio that's too loud hits the top of what a 16-bit sample can hold, called full scale, and gets flattened there.

Agentloudclipped0s2s4s6s8s

A reply is clipped when:

CheckRule
Clipped sample32,000 or more either way from zero, near the 32,767 maximum
Share of the clipMore than 0.1% of its samples are clipped

Reviewers heard clipping when as little as 0.1% of a reply's samples sat near full scale, so light clipping counts, but a few clipped samples on one loud syllable don't.

If there's nothing to count, the metric is skipped.

Example call

A call where one of four agent replies is pushed far past full volume.

Agentturn 1turn 3turn 5turn 7clean: loud0s5s10s15s20s
Agent turnWhat happensClipped?
1Normal volumeNo
3Three times louder, but every sample stays under 32,000No
58.4% of samples at or near full scaleYes
7Normal volumeNo
4 replies1 clipped → 3/4 = 0.75

FAQs

How is this different from Audio Glitch and Audio Integrity?
Both AudioGlitchMetric and AudioIntegrityMetric run this metric as one of their parts. This metric reports only clipping.
Is a loud agent the same as a clipped one?
No. A loud agent that stays under full scale isn't clipped. Use LoudnessMetric to check volume.
Does this metric call an LLM or an external speech model?
No. Detection is deterministic and runs locally over the audio, so it has no model or token cost.
Does it check the caller's audio too?
No. Only the agent's replies are scored. The caller is your simulator's TTS voice or a real customer, so their audio says nothing about the agent.

On this page