Skip to navigation
AgentsAgentBase

speech_finals

View as MarkdownOpen in Claude

Return a call’s recognizer finals, oldest first, once record_speech_finals() is on.

Parameters

call_id
strRequired

The call, as a tool request’s raw_data["call_id"].

since
float | NoneDefaults to None

Only the finals from this time on, in seconds since the epoch.

Returns

list[dict[str, Any]] — The finals, each {"text", "words", "timestamp"}:

  • text — the final’s text.
  • words — [{"word", "confidence"}], as the recognizer heard them.
  • timestamp — when the event was sent, in seconds since the epoch.

Empty for a call with no finals, or when recording is off.

Example

from signalwire import AgentBase, FunctionResult
agent = AgentBase(name="spell", route="/spell")
agent.prompt_add_section("Role", "You take spelled names.")
agent.record_speech_finals()
def check_name(args, raw_data):
finals = agent.speech_finals(raw_data["call_id"])
unsure = [w["word"] for f in finals for w in f["words"] if w["confidence"] < 0.6]
return FunctionResult(f"Unsure of: {unsure}")
agent.define_tool("check_name", "Check the spelled name",
{"type": "object", "properties": {}}, check_name)
agent.serve()