Docs

    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
    # 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 .yaml or .yml file is read as YAML, which needs PyYAML; the voice extra installs it. A .json file 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 a goal or lines, never both.

    A goal or lines

    A caller with a goalA caller with lines
    What it saysAn opening, then a line its model decides after each answer of the botExactly the lines, in order
    Hears the botYes: each answer is heard and written downNo: it waits for the bot to finish, then says the next line
    EndsWhen the goal is met, the caller would give up, or it reaches maxTurnsAfter its last line and the bot's answer
    NeedsA model that hears audio: yours, or SyntropyLabs' Gemini where it is set up for your organizationNothing but the voice
    Judged by Voice Task SuccessYes, against the goal and successCriteriaNo: with no transcript of the bot it is skipped

    Scenario fields

    FieldTypeDefaultLimits
    nametextrequired1 to 200 characters. The console and the summary show it.
    goaltextgoal or lines1 to 1,000 characters: what the caller wants, and what would satisfy it.
    personaEXPERT, NOVICE, ADVERSARIAL, VAGUE, CONTEXT_SWITCHER, IMPATIENT, or texta realistic, moderately patient callerFree text up to 500 characters. Each named persona is played as the text simulated user plays it.
    factsmappingnoneAt most 12, 500 characters each: what the caller knows and keeps back until asked, as key: value or key: { value, revealWhen }.
    openingtextwritten by the caller's model when the run startsUp to 500 characters: the caller's first line.
    successCriteriatext, or a list of textnoneUp 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.
    maxTurnswhole number8, or --max-turns1 to 20: caller lines after the opening. The caller ends sooner when its goal is met or it would give up.
    interrupt{ turn, afterBotMs }noneturn 1 to maxTurns, afterBotMs 0 to 30,000: before line turn, the caller cuts into the bot's answer that far in.
    lineslist of linesgoal or lines1 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.

    FieldTypeDefaultLimits
    texttextrequired1 to 500 characters, after trimming.
    waitmappingsee Wait rulesWhen the caller says the line.
    interruptAfterBotMswhole millisecondsnone0 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.

    RuleFieldsThe caller speaks
    bot_donesilenceMs: 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.
    fixedms: 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-speaker says (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_done defaults.
    • A wait written on the first line is played as written, whoever speaks first.
    • A wait with ms and no rule is a fixed wait. Without ms, rule is bot_done.
    • After the last line, the caller waits for the bot's answer by the bot_done defaults, then hangs up.

    Planned interruptions

    • interruptAfterBotMs: N makes 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 a bot_done one without startWithinMs. N must be less than its maxMs: 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
    # 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:

    voice-tests.json
    {
      "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, and mode for rule.
    • Quote a line that is only Yes, No, On or Off: 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 as text: ....
    • 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:

    Output
    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.

    EvalKit is built by SyntropyLabs. Published on PyPI and npm.