Voice
Voice test scenarios file
Every field of the YAML or JSON file a voice test run plays: callers with a goal or with exact lines, personas, facts, waits, planned interruptions and success criteria, with their types, defaults and limits.
evalkit voice-test run --scenarios FILE plays the callers of a YAML or JSON file, and evalkit voice-test init writes a starter one. Each caller has a goal, which it talks its way to, answering what your bot actually says, or exact lines, which it says as written. The file is checked before anything is sent, and a mistake names the file, the scenario and the line. The scenarios are sent with the run and kept on it, so the console shows what was played. Nothing is saved to a scenario set. Scenarios files need SDK 0.3.9 or later; without one, --about writes the callers for the run (see Test a voice bot).
The starter file
This is the file evalkit voice-test init writes: a refund desk, two callers with goals, the first impatient enough to cut in, and one with exact lines. init voice-tests.json writes the same as JSON, and --force overwrites a file that exists.
# voice-tests.yaml: callers for `evalkit voice-test run --scenarios voice-tests.yaml`
#
# Each scenario is one call. A caller with a goal talks to your bot until the goal is met or it gives
# up, answering what your bot actually says. A caller with lines says exactly those lines.
# Without a file, `evalkit voice-test run --about "what your bot does"` writes the callers for you.
# Limits: 50 scenarios; a goal of 1,000 characters; 20 turns a call; 40 lines, 500 characters each.
scenarios:
- name: Refund for a duplicate charge
goal: Get the second charge on order 4471 refunded and find out when the money arrives
persona: IMPATIENT
facts:
order_number: "4471"
successCriteria:
- The agent refunds the second charge
- The agent says when the refund will arrive
interrupt: { turn: 1, afterBotMs: 1500 }
- name: Refund outside the return window
goal: Get money back for headphones bought two months ago that stopped working last week
persona: NOVICE
successCriteria:
- The agent explains the 30-day return policy
- The agent offers store credit or a repair
- name: Opening hours, exact lines
lines:
- Hi, what are your opening hours on Saturday?
- Thanks, that's all.The file
- A
.yamlor.ymlfile is read as YAML, which needs PyYAML; thevoiceextra installs it. A.jsonfile is read as JSON. A file with another suffix is read as JSON, else as YAML. - The top level is
scenarios:with a list, or the list itself. Nothing else goes in the file: the bot's URL and format are options of the command. - Each scenario is one call, times
--repeats. A scenario has agoalorlines, never both.
A goal or lines
| A caller with a goal | A caller with lines | |
|---|---|---|
| What it says | An opening, then a line its model decides after each answer of the bot | Exactly the lines, in order |
| Hears the bot | Yes: each answer is heard and written down | No: it waits for the bot to finish, then says the next line |
| Ends | When the goal is met, the caller would give up, or it reaches maxTurns | After its last line and the bot's answer |
| Needs | A model that hears audio: yours, or SyntropyLabs' Gemini where it is set up for your organization | Nothing but the voice |
| Judged by Voice Task Success | Yes, against the goal and successCriteria | No: with no transcript of the bot it is skipped |
Scenario fields
| Field | Type | Default | Limits |
|---|---|---|---|
name | text | required | 1 to 200 characters. The console and the summary show it. |
goal | text | goal or lines | 1 to 1,000 characters: what the caller wants, and what would satisfy it. |
persona | EXPERT, NOVICE, ADVERSARIAL, VAGUE, CONTEXT_SWITCHER, IMPATIENT, or text | a realistic, moderately patient caller | Free text up to 500 characters. Each named persona is played as the text simulated user plays it. |
facts | mapping | none | At most 12, 500 characters each: what the caller knows and keeps back until asked, as key: value or key: { value, revealWhen }. |
opening | text | written by the caller's model when the run starts | Up to 500 characters: the caller's first line. |
successCriteria | text, or a list of text | none | Up to 20, 500 characters each. Voice Task Success judges a goal-based call against them and the goal; a scripted call's are stored and shown, not judged. |
maxTurns | whole number | 8, or --max-turns | 1 to 20: caller lines after the opening. The caller ends sooner when its goal is met or it would give up. |
interrupt | { turn, afterBotMs } | none | turn 1 to maxTurns, afterBotMs 0 to 30,000: before line turn, the caller cuts into the bot's answer that far in. |
lines | list of lines | goal or lines | 1 to 40 lines. |
A file holds at most 50 scenarios. A run places one call per scenario and repeat, at most 50 calls.
Line fields
A line of a scripted caller is its text, or a mapping with text and the fields below.
| Field | Type | Default | Limits |
|---|---|---|---|
text | text | required | 1 to 500 characters, after trimming. |
wait | mapping | see Wait rules | When the caller says the line. |
interruptAfterBotMs | whole milliseconds | none | 0 to 30,000, and less than the line's maxMs. See Planned interruptions. |
Wait rules
A wait starts when the previous line ends; for the first line, when the call opens. Every value is in milliseconds.
| Rule | Fields | The caller speaks |
|---|---|---|
bot_done | silenceMs: 0 to 10,000, default 700. maxMs: 1,000 to 60,000, default 15,000. startWithinMs: optional, 0 to maxMs. | Once the bot has spoken, at least 100 ms of speech, and then been silent for silenceMs; at maxMs at the latest. With startWithinMs, also when no bot speech has started by then; once it has, only silenceMs and maxMs apply. The wait after the bot's answer is the caller's, so Voice Silence does not count it, however long silenceMs is. |
fixed | ms: 0 to 60,000, required. | ms after the previous line ends, whatever the bot is doing. The time after the bot stops is the caller's wait, which Voice Silence does not count. |
- A line with no
wait: the first line waits as--first-speakersays (see Who speaks first), and every other line{rule: bot_done, silenceMs: 700, maxMs: 15000}. - A caller with a goal waits the same way: its opening as a first line does, and each later line for the bot's answer by the
bot_donedefaults. - A
waitwritten on the first line is played as written, whoever speaks first. - A
waitwithmsand noruleis a fixed wait. Withoutms,ruleisbot_done. - After the last line, the caller waits for the bot's answer by the
bot_donedefaults, then hangs up.
Planned interruptions
interruptAfterBotMs: Nmakes the caller say the line N ms into the bot's answer to the line before, while the bot is still speaking. On the first line, it cuts into the greeting.- Such a line has no
wait, or abot_doneone withoutstartWithinMs. N must be less than itsmaxMs: 15,000 when the wait is left out. - A caller with a goal plans its interruption with
interrupt: { turn, afterBotMs }instead, and says a short line its model wrote the turn before. - If the bot stops speaking before N ms, the caller says the line once the bot has been quiet for the wait's
silenceMs, as a normal turn, and Voice Interruption Stop leaves it out. See Planned interruptions.
A complete example
Every field, in four calls: a caller with a goal, a free-text persona, a fact it gives only when asked, its own opening, a turn limit and a planned interruption; then exact lines with a wait with longer limits, a quoted Yes, a greeting that may not come, a fixed wait, and a planned interruption.
# voice-tests.yaml
scenarios:
- name: Move a booking
goal: Move Friday's 7 pm booking for two to Saturday at the same time
persona: A regular who is polite but in a hurry, calling from a train
facts:
booking_name: { value: Okafor, revealWhen: the agent asks whose booking it is }
phone: "+44 7700 900123"
opening: Hi, I need to change a booking I made for this Friday.
successCriteria:
- The agent finds the booking under Okafor
- The agent moves it to Saturday at 7 pm and reads it back
maxTurns: 10
interrupt: { turn: 2, afterBotMs: 1200 }
- name: Book a table for two
successCriteria:
- The agent books a table for two on Friday at 7 pm
lines:
- Hi, I'd like to book a table for Friday.
- text: Two people, at seven in the evening.
wait: { rule: bot_done, silenceMs: 900, maxMs: 20000 }
- "Yes"
- name: A bot that may not greet
lines:
- text: Hello, is this the booking line?
wait: { rule: bot_done, startWithinMs: 2000 }
- text: Do you have a table tonight?
wait: { rule: fixed, ms: 2000 }
- name: Caller cuts in
lines:
- What are your opening hours this week?
- text: Sorry, only Saturday.
interruptAfterBotMs: 1200
- Thanks, that's all.The same shape as JSON, with every line written as a mapping:
{
"scenarios": [
{
"name": "Caller cuts in",
"lines": [
{ "text": "What are your opening hours this week?" },
{ "text": "Sorry, only Saturday.", "interruptAfterBotMs": 1200 },
{ "text": "Thanks, that's all.", "wait": { "rule": "bot_done", "silenceMs": 700, "maxMs": 15000 } }
],
"successCriteria": ["The agent stops talking and answers the new question"]
}
]
}Call length
Each call has a time budget. For a caller with lines: for every line, its longest wait and its length, added up, plus 15 seconds for the last answer and 5 seconds more, rounded up to the second and at most 10 minutes. A scenario whose lines alone take longer than 10 minutes is refused. A caller with a goal gets its budget from the run's plan, at most 10 minutes, and the call page shows it. A call that runs past its budget ends with the error max_call and fails.
Spelling and YAML pitfalls
- snake_case is accepted:
success_criteria,max_turns,after_bot_ms,reveal_when,interrupt_after_bot_ms,silence_ms,max_ms,start_within_ms, andmodeforrule. - Quote a line that is only
Yes,No,OnorOff: YAML reads it as true or false. Quote a fact such as"4471"to keep it text. - Quote a line that holds
:, or write it astext: .... - An unknown field is refused, with the fields that are allowed.
Each mistake stops the command with exit code 2 before anything is sent. For example:
evalkit voice-test: voice-tests.yaml: scenarios[0] ("Confirm"): lines[1] is true, not text; in YAML, quote a line such as "Yes" or "No"
evalkit voice-test: voice-tests.yaml: scenarios[0] ("Colon"): lines[0] has no text (found ['Order number']); in YAML, a line with a colon in it needs quotes, or write it as text: ...
evalkit voice-test: voice-tests.yaml: scenarios[0] ("Caller cuts in"): lines[1]: interruptAfterBotMs (15,000) must be less than the wait's maxMs (15,000), when the caller stops waiting for the bot
evalkit voice-test: voice-tests.yaml: unknown top-level fields ['url'] (the file holds scenarios only; the bot's URL and format are command-line options)Scenarios from Python
evalkit.voicetest.load_scenarios(path) reads a file and raises ScenarioError naming the line at fault. evalkit.voicetest.run(scenarios=...) takes what it returns, a file's path, a list in the file's shape, or the scenarios evalkit.generate_scenarios(..., scripted_turns=True) returns, whose turns become the lines. run(about=...) writes the callers instead. See From Python.
Scenario ids and session tokens
Each scenario's id, from a file or written from --about, is scn_<runId>_<index>, its position from 0. Each call's session token is sdk:<runId>:scn_<runId>_<index>:<callIndex>; with --agent, it starts with the agent's id instead of sdk. Your bot reads the token to join the call's session: see Trace a voice bot.