- Subject
- Software
- Date
- Read
- 12 min
How I test a speech-to-speech AI on a phone line
A new voice model shipped and I needed proof before switching. How I built an eval that fakes phone calls to my own AI phone line, hears what the model actually said, and grades it, and the mistakes the eval made before it could be trusted.
Contents
When Nova 2.5 Sonic came out, AWS said it was faster and better at calling tools than Nova 2 Sonic, the model my voice agent runs on. But “the vendor says so” isn’t a reason to swap the model under something people call for answers, and neither is “a few test calls sounded fine”. I wanted the same questions asked of both models, scored the same way.
Testing a chatbot is easy: send text, read text. A speech-to-speech model is harder. It takes audio in and gives audio back, it decides for itself when you’ve stopped talking, and the text it reports isn’t always what it said. So the eval has to be a caller: speak, wait, listen, then grade.
This post is how I built that: faking the phone call, knowing when the agent has finished, hearing what it actually said, and grading it. It’s about Nova Sonic on a phone line, but most of it applies to any speech-to-speech agent.
The eval got it wrong at first. Its first run said Nova 2.5 was much worse: it passed 15 of 23 test calls, against 20 for Nova 2. After I fixed the eval and reviewed the failures by hand, the two were tied on accuracy, and Nova 2.5 started speaking about 0.6 seconds sooner at the median (measured at my server). I switched. The eval’s mistakes are numbered through the post, because each is an easy one to make.
The system under test
The agent answers phone calls about one organization: opening hours, schedules, events, who to contact, how to do things. Its answers have to come only from that organization’s own documents, which change every week.
Twilio carries the call audio to a small server that streams it to Amazon Nova Sonic, a speech-to-speech model on Bedrock. When Nova needs a fact it calls a lookup tool, which asks Claude to answer from the documents. A chat version of the same agent, plain text behind an API, is tested separately through the deployed API, the same route the mobile app uses.
I looked at existing tools first. AWS’s open-source Nova Sonic eval harness has good ideas, like an LLM playing the caller, but it calls Nova directly with its own prompt and tools, so it tests the model, not my system. Bedrock Model Evaluations is text-only, and AgentCore Evaluations grades a running agent’s traces rather than comparing two models before a switch. So I built a small eval around the real system and borrowed the ideas.
Faking the phone call
The eval doesn’t make real calls. No phone numbers, no Twilio account, no call charges.
On a real call, Twilio connects to the agent’s server over a WebSocket and sends the audio as
JSON messages (its Media Streams protocol): connected, then start with the call’s details,
then media messages carrying 20 ms of audio each, then stop. So the eval impersonates Twilio.
It opens a WebSocket straight to the agent’s server, run locally with the deployed settings, and
speaks the same protocol. The server can’t tell it from a real call.
- The caller’s voice is Amazon Polly, generated at 8 kHz, converted to μ-law like a real phone line, and sent at real-time speed, one 20 ms frame at a time.
- The line is never silent. Between questions the eval keeps sending silence frames, as a real call would. The model decides you’ve finished talking by listening, so a stream that just stops is not a pause.
- The agent’s words come two ways. The server has an eval mode, off in every deployed environment, that sends the model’s text and tool calls over the same WebSocket. And the audio it sends back is saved and transcribed with Amazon Transcribe, so the eval knows what was said, not just what was written.
“Run locally” means the same server code the deployed container runs, started on my computer. Its settings once drifted from the deployed ones and would have quietly tested the old model, so now it gets every setting from the same source as the deployed system, never from a hand-kept list. Only what’s passed on the command line, like the model under test, overrides them.
So the eval tests everything I own plus the model: the prompt, the lookups, the “one moment” filler, the audio conversion, turn-taking, and Nova itself. It skips Twilio’s side and the phone network, so one real call by hand is the smoke test before a release. Testing the model alone would have missed nearly every problem this eval found, because they lived in my layer.
When has the agent finished talking?
On a phone call, nobody says “I’m done.” The model just stops talking, and the eval has to decide when it’s safe to ask the next question. Get that wrong and answers get mixed together.
1. The eval talked over the agent. At first it went wrong two ways:
- It asked before the greeting was over. When a call connects, the agent greets the caller. The eval started asking while the greeting was still going, and part of the greeting was counted as the answer.
- It mistook a pause for the end. After answering, the model often pauses, then adds “Is there anything else you’d like to know?” The eval asked its follow-up in that pause, so the “anything else?” was counted as part of the next answer.
The fix has two parts. First, wait for real quiet: a turn is over only when the model has given its answer after its last lookup, and then nothing at all has come from it for 3.5 seconds. At 2.5 seconds the “anything else?” still slipped into the next answer; at 3.5 it didn’t. That’s from one test, not careful tuning. Second, ignore anything the agent says while the question is still being asked, so a leftover greeting can’t count as the answer.
Hearing what it actually said
2. The model’s text can be missing what it said aloud. One case is a caller in crisis. The right answer includes the 988 crisis line. On the phone, the model said it; its text didn’t include it. A grader reading only the text would have failed a correct, safety-critical answer.
So a check passes if either the text or the transcribed audio meets it:
// Simplified. A check passes if the model's text OR the transcribed
// audio meets it...
const either = (check) => [text, heard].some(check);
// ...but "must not say" has to hold for both.
const neither = (check) => ![text, heard].some(check);
either((a) => hasTime(a, '9:15'));
neither((a) => a.includes('Monday'));
3. But the transcription mishears too. In phone-quality audio, Transcribe heard “twenty-first” as “20th”. That alone caused three of Nova 2.5’s failures and one of Nova 2’s. I listened to the saved audio: the model had said the right date. The rule checks weren’t fooled, since they pass on text or audio, but the judge (below) reads both and believed the transcript. Its instructions now say that when the two give the same number, date or name differently, trust the text. Keep the audio.
Grading the answer
There are 24 test cases, spread over the kinds of things callers ask: schedules, contact details, events, how to do something, questions it shouldn’t be able to answer, a crisis, and one in Spanish (text only, so the phone runs 23). Two have a follow-up question. Made-up examples in the same style:
- “Is the office open on Friday afternoon?” (No, it closes at noon.)
- “What’s the Wi-Fi password at the building?” (It mustn’t invent one, and should offer the office’s contact details.)
The expected answers are placeholders like {{schedule:Saturday}}, filled in at run time from
the system’s stored data, so the tests don’t change when the documents do. The eval checks that
the agent reports the stored data correctly, not that the data itself is right.
Each answer is graded two ways.
Rule checks come first: what the answer must include, what it must not say, which times it must give, and which tool it must call. Speech is not text, so everything is normalized first: “nine fifteen” becomes 9 15, “twenty first” becomes 21. Times need one more rule, from a real bug: 5:00 can be said as “five”, but the 5 in “five thirty” must not count.
// Simplified. "nine fifteen" matches 9:15; "5:00" must not match "5 30".
function hasTime(answer: string, time: string): boolean {
const [hour, minutes] = time.split(':'); // "9:15" → "9", "15"
const words = norm(answer).split(' '); // number words → digits
return words.some((word, i) => {
if (word !== hour) return false;
const next = words[i + 1];
if (minutes === '00') return !isMinutes(next); // "5", but not "5 30"
return next === minutes; // "9 15"
});
}
Rule checks are cheap, fast and never change their mind. They can’t tell whether an answer was helpful.
A model as judge does that. It’s Claude Sonnet 4.6 on Bedrock at temperature 0 (its most repeatable setting), and it stays the same while the agent’s model changes. Claude also answers the agent’s lookups, but that part is the same for both models; the judge is a separate call with its own instructions. It scores four things from 1 to 5: accurate, grounded in the documents, helpful, and format (on the phone: natural sentences, three items at most, no URLs read aloud).
4. The judge scores consistently but applies its own pass mark badly. On the first run it
returned 5, 5, 5 and "pass": false. So the judge only scores, and code decides:
// The judge scores; code decides. Its own "pass" field is ignored.
const pass =
scores.accuracy >= 4 && scores.grounded >= 4 && scores.helpful >= 3;
Format is reported, but it doesn’t decide pass or fail.
5. Judging against summaries made true facts look invented. At first the judge got the same short summaries the agent uses for quick answers. When the agent looked up a true detail in the full documents, the judge marked it “not grounded”, because it wasn’t in the summary. Now the judge also gets the full text of every source document, about 42,000 tokens (estimated from 168,753 characters), behind a Bedrock cache point so repeated calls can reuse it.
Don’t let the eval load-test you
6. Running the questions in parallel throttled the system being tested. The chat eval sent all its questions at once. The agent’s lookups and the judge both call Claude and share one quota, so lookups were throttled, answers failed, and the eval reported 13 of 24 passing, mostly measuring its own load. Now cases run one at a time and grading happens afterwards, with backoff. With that fix and the full documents for the judge, chat went from 13 of 24 to 22 of 24, and held there on a later run.
The results
A run puts the same 23 phone calls to each model, and each call passes or fails. Here’s how many passed as I fixed the eval:
| Calls passed, out of 23 | Nova 2.5 Sonic | Nova 2 Sonic |
|---|---|---|
| First run | 15 | 20 |
| Second run, after fixing the eval | 16 | 20 |
| Second run, checked by hand | about 21 | about 21 |
The first run made Nova 2.5 look clearly worse. The second run had three eval fixes in it (text-or-audio checks, better spoken-number handling, and ignoring text from before the question ended), and the gap barely moved. So I went through each remaining failure with Claude’s help, listening to the audio where it mattered. Six weren’t the model’s fault: four were the “twenty-first” mishearing, and two were the eval’s own bugs (“two in the afternoon” wasn’t recognized as 2:00 in one kind of check, and “call the office” without the number was failed). Counting those as passes, both models land at about 21 of 23. The last row isn’t a new run; it’s the second run, rescored by hand. The models tie.
Speed did differ. This is time to first sound, from the end of the question to the first audio leaving my server. p50 is the median call; p90 means 9 in 10 calls were at least that fast.
| p50 | p90 | |
|---|---|---|
| Nova 2.5 Sonic | 1.0 s | 1.3 s |
| Nova 2 Sonic | 1.6 s | 2.0 s |
The phone network adds its own delay, which I didn’t measure, but the comparison between models holds. Time to the end of the answer was about the same (9.0 s for Nova 2.5, 9.2 s for Nova 2, at p50). Same accuracy and a faster start, so I switched.
After the switch, with every fix in this post, 20 of 23 calls passed with Nova 2.5, and 22 of the 23 calls passed every rule check. Two of the three failures were the eval again, both since fixed. One was a real error: a wrong time in a list, in a case that had passed in earlier runs. The same question passes some runs and fails others, so one run of 23 calls is a sample, not a verdict. I haven’t measured how much runs vary yet; that’s the next step before calling a close result.
What it found that was real
Fixing the eval wasn’t the point. It also found real problems:
- Promises the service can’t keep. Asked “Can you pray for my mom? She’s in the hospital,” both voice models and the chat agent promised to. Nothing in the system would ever act on that. Telling the agent not to promise swung it the other way (“As an AI, I can’t pray”), which is cold at exactly the wrong moment. Pointing it to what the service really offers fixed it.
- General knowledge dressed as fact. The chat agent added “most places require…” practice that wasn’t in the documents. Not fixed yet; it passes some runs and fails others.
- Mislabeled hours. Another room’s opening hours were filed as the office’s. The judge, with the full documents, spotted it before I did.
That fix tripped up the judge: it marked the app feature as invented, because the app isn’t in the source documents. A judge needs to know what the product can do, not just what the documents say.
Cost and time
A phone run takes about 12–13 minutes per model, one call at a time; the chat run takes around 5 (estimate).
Everything runs on Bedrock in my AWS account, billed per token. The judge is the part I’ve estimated: with the documents cached, a two-model run should cost a dollar or two in judge tokens (an estimate, not checked against billing). Nova Sonic, the lookups, Polly and Transcribe add to that, and I haven’t measured them.
Takeaway
Testing a speech-to-speech model means testing a conversation, not a string. The eval has to speak at real speed, keep the line open, wait until the model has really finished, and grade what it said aloud as well as what it wrote. And it has to go through your own system, because that’s where most of the problems were.
An eval is also a program, with bugs like any other. Mine gave the wrong verdict first. Before you trust “the new model is worse”, check that the eval can hear what the model said, that the judge has the information the model had, and that it isn’t measuring its own load. Then listen to the failures yourself.