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

Pitch Variation

Beta
Multi-turn
Referenceless
Chatbot
Voice

The pitch variation metric checks whether your voice agent's pitch moves naturally within a reply, rather than sounding flat and robotic. If you set an upper limit, it also flags a voice that swings wildly up and down. It returns the share of agent replies whose pitch varies within range, between 0 and 1.

0.0s / 6.9s

Required Arguments

To use the PitchVariationMetric, you'll have to provide a ConversationalTestCase with:

  • audio on the agent's turns, one clip per reply, 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 PitchVariationMetric() 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 PitchVariationMetric
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 = PitchVariationMetric(threshold=0.8)
evaluate(test_cases=test_cases, metrics=[metric])

There are FOUR optional parameters specific to the PitchVariationMetric, on top of the common voice metric parameters:

  • [Optional] min_spread_semitones: an integer for the least pitch spread, in semitones, a reply may have before it counts as monotone. Must be 0 or more. Defaulted to 1.
  • [Optional] max_spread_semitones: an integer for the most pitch spread, in semitones, a reply may have before it counts as erratic. Must be greater than min_spread_semitones. Defaulted to None, which turns the erratic check off.
  • [Optional] eval_mode: "deterministic" or "hybrid". In "hybrid", each flagged 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 to HumeDecisionModel().

A value outside these limits raises a ValueError.

As a standalone

You can also run the PitchVariationMetric 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 reply with too little or too much pitch movement shows up in score_breakdown. Here is what the example call returns:

{
    "eligible_turns": 4,
    "turns_with_events": 1,
    "events": [
        {
            "type": "monotone",
            "turn": 3,
            "timing_source": "turn_timestamps",
            "description": "Reply sounded monotone",
            "pitch_spread_semitones": 0.0,
            "offset_seconds": 0.0,
            "duration_seconds": 5.0,
            "start_time": 10.5,
            "mark": "whole_reply",
        }
    ],
    "skipped": [
        {
            "turn": 9,
            "error": "Reply has under 1s of voiced speech to follow its pitch.",
        }
    ],
}
FieldWhat it means
typeMonotone if the pitch barely moved, erratic if it swung too widely (only when max_spread_semitones is set)
pitch_spread_semitonesHow widely the reply's pitch moved, in semitones

Each event covers the whole reply: offset_seconds is 0 and duration_seconds is the clip's length. Replies with under 1 second of voiced speech, or audio 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 flagged. The score is the share that weren't.

How Is It Calculated?

The PitchVariationMetric score is calculated according to the following equation:

Pitch Variation=Number of Agent Replies With a Pitch Spread in RangeTotal Number of Scored Agent Replies\text{Pitch Variation} = \frac{\text{Number of Agent Replies With a Pitch Spread in Range}}{\text{Total Number of Scored Agent Replies}}

The metric reads per-turn audio, one agent clip at a time, or replies cut from stereo full call audio when no turn has audio. The caller's turns are never checked.

Which replies are scored

Agentturn 1turn 3reply 1too short0s2s4s6s

The metric tracks the pitch of every 40 ms of the clip, between 70 and 500 Hz, and leaves out stretches that are near silent or have no clear pitch (such as "s" or "f" sounds). What's left is the voiced speech. A reply is scored if it has at least 1 second of it.

Pitch spread criteria

A reply's pitch spread is how far its 40 ms pitches typically sit from the reply's median pitch, in semitones. Because it uses a median, a single cracked word doesn't move it. Cracks are judged by Abrupt Pitch Jump instead.

CheckRule
MonotoneSpread under min_spread_semitones (1 by default), on a reply at least 4 seconds long
ErraticSpread over max_spread_semitones, only when you set one

A flat reply only sounds robotic once it runs a few seconds, so a shorter one is never flagged as monotone. It still counts towards the score.

If no agent reply has enough voiced speech, the metric is skipped.

Second check

In the hybrid eval mode, each flagged 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:

  • Monotone: "Does the speaker sound flat and monotone, like a robot reading?"
  • Erratic: "Does the speaker's pitch swing up and down erratically, in a way that sounds unnatural?"

If the model judges "no" more likely than "yes", the reply is dismissed and doesn't count against the score.

Example call

A call with five agent replies: one sounds natural, one is read flat for 5 seconds, one is as flat but only 3 seconds long, one swings widely, and one is too short to judge. Each row is one agent reply and its pitch spread.

Agent13579flat, under 4 swide, no limit setskipped0s5s10s15s20s25s30s
Agent turnLengthPitch spreadFlagged?
15 s2.4 semitonesNo
35 s0.0 semitonesYes (monotone)
53 s0.0 semitonesNo, under 4 seconds
74 s8.9 semitonesNo, no upper limit by default
90.8 sUnder 1 s of voiced speechSkipped
4 replies1 flagged → 3/4 = 0.75

With max_spread_semitones=6, turn 7 is also flagged as erratic, and the score drops to 2/4 = 0.5.

FAQs

Why semitones rather than Hz?
A 20 Hz swing is large for a deep voice and small for a high one. Semitones measure pitch the way listeners hear it, so the same limit works for any voice.
Does this metric call an LLM or an external speech model?
Not by default. Detection is deterministic and runs locally over the audio, so it has no model or token cost. In the "hybrid" eval mode, each flagged reply is also checked by an audio decision model, at one paid request per flagged reply.
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