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

Beta
Multi-turn
Referenceless
Chatbot
Voice

The pitch consistency metric checks whether your voice agent keeps the same voice from one reply to the next, rather than sounding clearly deeper or higher in one of them. It returns the share of agent replies that stay close to the agent's typical pitch, between 0 and 1.

CallerAgent
0.0s / 19.1s

Required Arguments

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

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

There is ONE optional parameter specific to the PitchConsistencyMetric, on top of the common voice metric parameters:

  • [Optional] max_shift_semitones: an integer for how far, in semitones, a reply's pitch may sit from the agent's typical pitch. Must be greater than 0, or a ValueError is raised. Defaulted to 3.

As a standalone

You can also run the PitchConsistencyMetric 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 whose pitch drifted too far shows up in score_breakdown. Here is what the example call returns:

{
    "eligible_turns": 5,
    "turns_with_events": 2,
    "events": [
        {
            "type": "pitch_shift",
            "turn": 3,
            "timing_source": "turn_timestamps",
            "description": "Voice sat 4 semitones lower than in the agent's other replies",
            "pitch_base_hz": 161.8,
            "shift_semitones": -3.8,
            "offset_seconds": 0.0,
            "duration_seconds": 7.0,
            "start_time": 12.5,
            "mark": "whole_reply",
        },
        {
            "type": "pitch_shift",
            "turn": 7,
            "timing_source": "turn_timestamps",
            "description": "Voice sat 4 semitones higher than in the agent's other replies",
            "pitch_base_hz": 257.0,
            "shift_semitones": 4.1,
            "offset_seconds": 0.0,
            "duration_seconds": 7.0,
            "start_time": 32.5,
            "mark": "whole_reply",
        },
    ],
    "skipped": [
        {
            "turn": 11,
            "error": "Reply has under 3s of voiced speech to follow its pitch.",
        }
    ],
}
FieldWhat it means
pitch_base_hzThe reply's base pitch, in Hz
shift_semitonesHow far that sits from the agent's typical pitch, in semitones. Negative when deeper

Each event covers the whole reply: offset_seconds is 0 and duration_seconds is the clip's length. The description rounds the shift to a whole number. Replies with under 3 seconds 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 compared and turns_with_events how many drifted. The score is the share that didn't.

How Is It Calculated?

The PitchConsistencyMetric score is calculated according to the following equation:

Pitch Consistency=Number of Agent Replies Near the Typical PitchTotal Number of Scored Agent Replies\text{Pitch Consistency} = \frac{\text{Number of Agent Replies Near the Typical Pitch}}{\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 3turn 5turn 7reply 1reply 2reply 3under 3 s voiced0s5s10s15s20s25s

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 3 seconds of it, since that is how long a voice's base pitch takes to settle.

It takes at least 3 scored replies to tell which one is off. With fewer, the metric is skipped.

Pitch shift criteria

Each reply is judged on its base pitch: the low end its voice keeps returning to between the words it stresses. It moves far less from reply to reply than the middle of the voice, so a stressed word or a question doesn't make a reply look off.

CheckRule
Base pitchThe 10th percentile of the reply's 40 ms pitches
Check readingThe 20th percentile, read the same way, since a few creaky frames can drag the very lowest pitch down on their own
Typical pitchThe median base pitch across all counted replies, so one odd reply is flagged on its own instead of pulling the typical pitch towards it
ShiftHow far the reply sits from the typical pitch, by both readings. Only the part they agree on counts: 0 if they point in opposite directions, otherwise the smaller of the two
Pitch shiftA shift of more than max_shift_semitones (3 by default) above or below

Example call

A call with six agent replies, all 7 seconds long except the last: most have a base pitch near 200 Hz, one is clearly deeper, one clearly higher, and the last is too short to judge. Each row is one agent reply, its base pitch and how far that is from the typical 201.9 Hz.

Agent1357911skipped0s5s10s15s20s25s30s35s40s45s50s55s
Agent turnBase pitchShiftFlagged?
1201.9 Hz0 semitonesNo
3161.8 Hz−3.8 semitonesYes
5209.9 Hz+0.7 semitonesNo
7257.0 Hz+4.1 semitonesYes
9197.0 Hz−0.4 semitonesNo
11Under 3 s of voiced speechSkipped
5 replies2 flagged → 3/5 = 0.6

FAQs

How is this different from voice consistency?
VoiceConsistencyMetric runs this metric together with loudness consistency and scores the share of replies neither flagged. This metric checks pitch only and points to the replies that drifted.
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