Skip to main content

Usage guide

Setup, environment variables, and Python/JavaScript/Go usage examples.

TurnDetector

End-of-turn detector: decides when the caller has finished speaking. One class selected by model: "namo" (the default), "namo-inference", "echo-small", or "echo-large". Which extra params apply depends on the model (see __init__).

Constructor

model
TurnDetectorModel | str
default:"namo"
Which detector to use: "namo" (the default), "namo-inference", "echo-small", or "echo-large".
threshold
float
default:"0.7"
End-of-turn probability cutoff, 0.0–1.0. Applies to every model. Default 0.7.
language
Optional[str]
BCP-47 language hint. Only used by the "namo" model.
host
Optional[str]
Inference service address. Inference models only.
auth_token
Optional[str]
Inference service auth token. Inference models only.
base_url
Optional[str]
Inference service base URL. Inference models only.

aclose

Release any resources held by the provider.

cleanup

Perform any additional teardown required by the provider.

detect_end_of_utterance

Determine whether the current utterance has ended.
chat_context
Any
required
The conversation context used to evaluate the utterance.
threshold
Optional[float]
Optional probability threshold overriding the configured one.
returns
bool
True if the end-of-utterance probability meets or exceeds the threshold, otherwise False.

emit

Emit an event, invoking all registered handlers with the given arguments. Handlers are called in registration order. Coroutine handlers are scheduled on the running event loop. If the emitter is closed, the call is a no-op.
event
T
required
The event to emit.

get_eou_probability

Return the estimated probability that the current utterance has ended. Reads the most recent detection result from the active session, falling back to 0.5 when no result is available or the value cannot be parsed.
chat_context
Any
required
The conversation context used to evaluate the utterance.
returns
float
The end-of-utterance probability in the range 0.0 to 1.0.

off

Remove a previously registered handler for an event. If the handler is not registered for the event, the call is a no-op.
event
T
required
The event the handler was registered for.
callback
Callable[..., Any]
required
The handler to remove.

on

Register a handler for an event. Can be used directly by passing a callback, or as a decorator when callback is omitted.
event
T
required
The event to listen for.
callback
Callable[..., Any] | None
The handler to invoke when the event is emitted. If None, a decorator is returned that registers the decorated function.
returns
Callable[..., Any]
The registered callback when callback is provided, otherwise a decorator that registers and returns the function it wraps.

set_threshold

Update the end-of-utterance probability threshold.
threshold
float
required
The new probability threshold.