📍 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 Loop

Beta
Multi-turn
Referenceless
Chatbot
Voice

The audio loop metric checks whether your voice agent's audio gets stuck repeating the same chunk, as in "Your order, your order, your order". It returns the share of agent replies with no loop, between 0 and 1.

0.0s / 5.9s

Required Arguments

To use the AudioLoopMetric, 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 AudioLoopMetric() 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 AudioLoopMetric
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 = AudioLoopMetric(threshold=0.8)
evaluate(test_cases=test_cases, metrics=[metric])

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

As a standalone

You can also run the AudioLoopMetric 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 loop shows up in score_breakdown as its own event. Here is what the example call returns:

{
    "eligible_turns": 4,
    "turns_with_events": 1,
    "events": [
        {
            "type": "audio_loop",
            "turn": 3,
            "offset_seconds": 1.25,
            "duration_seconds": 0.76,
            "start_time": 8.75,
            "mark": "range",
            "timing_source": "turn_timestamps",
            "description": "Audio repeated for 0.8s",
        }
    ],
    "skipped": [],
}

Loop events carry only the fields all voice events share. offset_seconds is where the first repeat starts, and duration_seconds covers every repeat after the original. Clips that can't be decoded are listed under skipped.

eligible_turns is how many agent replies were counted and turns_with_events how many had a loop. A reply with several loops counts once. The score is the share that had none.

How Is It Calculated?

The AudioLoopMetric score is calculated according to the following equation:

Audio Loop=Number of Agent Replies Without a LoopTotal Number of Agent Replies\text{Audio Loop} = \frac{\text{Number of Agent Replies Without a Loop}}{\text{Total Number of Agent Replies}}

Loop criteria

A loop is a chunk of audio that plays three or more times in a row. Matching compares how alike the sound is, not exact bytes, so a loop is still found after the audio is re-encoded on its way through the call.

Agentchunkrepeats0s1s2s3s4s5s6s
CheckRule
Chunk length0.2 to 2 seconds, and no more than a third of the clip
MatchEach 40 ms of the chunk matches the same 40 ms one chunk later, at 0.9 correlation or more
RepeatsThe match holds for at least two chunk lengths, so the chunk plays three times
Not a steady soundThe level inside the chunk varies by at least 3 dB

Near-silent moments neither confirm nor break a match, so pauses inside a repeated phrase don't split it. A steady drone matches itself at every delay, so the last check leaves it to Held Tone.

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

Example call

A call where one of four agent replies gets stuck on a quarter-second syllable.

Agentturn 1turn 3turn 5turn 70s5s10s15s20s
Agent turnWhat happensLoop?
1Normal speechNo
3A 0.25 s syllable plays four times in a row, from 1 s into the clipYes
5Normal speechNo
7Normal speechNo
4 replies1 loop → 3/4 = 0.75

FAQs

Can natural speech be flagged as a loop?
Rarely. Speech doesn't repeat itself that closely for that long. A replayed audio buffer does, even after re-encoding.
How is this different from Echo?
A loop is the agent's own stream playing the same chunk again. EchoMetric looks for the agent's voice coming back on the caller's side of the call.
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