Voice Naturalness
The voice naturalness metric measures how naturally your voice agent speaks across a conversation. It analyzes the audio on each assistant turn and returns a score between 0 and 1, where a higher score indicates more natural-sounding speech.
Usage
Voice metrics evaluate calls produced by the ConversationSimulator in voice mode. Start with one ConversationalGolden, simulate one call, then evaluate the returned test case:
from deepeval import evaluate
from deepeval.dataset import ConversationalGolden
from deepeval.metrics import VoiceNaturalnessMetric
from deepeval.simulator import ConversationSimulator
from deepeval.voice import ElevenLabsConnector, VoiceConfig
golden = ConversationalGolden(
scenario="The user wants to change a restaurant reservation.",
expected_outcome="The agent confirms the new reservation date.",
)
simulator = ConversationSimulator(
voice_config=VoiceConfig(
connector=ElevenLabsConnector(agent_id="your-agent-id"),
)
)
test_case = simulator.simulate([golden])[0]
metric = VoiceNaturalnessMetric(threshold=0.7)
evaluate(test_cases=[test_case], metrics=[metric])The simulator records the audio and transcript on each turn. You do not need to manually construct a ConversationalTestCase or Audio object.
There are FIVE optional parameters when creating a VoiceNaturalnessMetric:
- [Optional]
threshold: a number representing the minimum passing score. Set it toNoneto run the metric in score-only mode. Defaulted to0.5. - [Optional]
include_reason: a boolean which, when set toTrue, includes a summary of the evaluation score. Defaulted toTrue. - [Optional]
strict_mode: a boolean which, when set toTrue, requires a perfect score. Any score below 1 becomes 0, and the threshold is set to 1. Defaulted toFalse. - [Optional]
verbose_mode: a boolean which, when set toTrue, includes the score breakdown in verbose metric logs. Defaulted toFalse. - [Optional]
flaky: a boolean which, when set toTrue, marks the metric as flaky. Defaulted toFalse.
The metric's per-turn diagnostics include:
{
"eligible_turns": 1,
"turns": [
{
"turn": 1,
"score": 0.91,
"speaking_rate_wpm": 154.3,
"silence_fraction": 0.08,
"pitch_variation_hz": 22.7,
"clipping_fraction": 0.0,
"dropout_events": 0,
"loop_events": 0,
}
],
}How Is It Calculated?
VoiceNaturalnessMetric evaluates assistant turns only. For each decodable assistant audio clip, it:
- Decodes the clip to mono PCM samples.
- Measures clipping, short dropouts, repeated audio windows, silence, estimated signal-to-noise ratio, speaking rate, and pitch variation.
- Starts the turn at a score of 1 and applies bounded penalties for unnatural acoustic behavior.
- Clamps the turn score between 0 and 1.
- Averages all eligible assistant-turn scores.
The largest clipping penalty is 0.35. Dropouts can subtract up to 0.25, and repeated audio can subtract up to 0.2. Smaller penalties apply to:
- silence occupying more than 45% of the clip
- an estimated signal-to-noise ratio below 15 dB
- a speaking rate below 80 or above 240 words per minute
- pitch variation below 4 Hz or above 90 Hz
If an assistant turn has no audio, the metric skips that turn. If no assistant turn contains decodable audio, the metric returns no score and marks the evaluation as skipped.
FAQs
Does this metric call an LLM or an external speech model?
Do I need a transcript?
content is used with the audio duration and detected silence to estimate speaking rate.Does the metric evaluate user audio?
role is "assistant" contribute to the score.