Turn detection
Find out whether a caller has finished their turn, from the audio of how their speech ends.
Turn detection lets you find out whether a caller has finished their turn. You send the caller's audio, and the response carries the probability that the caller is done. The model reads the audio itself, so there is no transcription step to run first.
| Transport | Send | Returns |
|---|---|---|
POST /v1/turns | One audio clip | One decision for the moment the clip ends |
WebSocket /v1/turns | The caller's audio as it arrives | An event at each turn boundary |
Use turn detection when your agent has to choose the moment to reply: soon after a finished sentence, and not during a pause in the middle of one.
Get an API key
Create a Sprag account and open API keys in the app to generate one.
Copy the key immediately. The full value is shown once and is not recoverable after you leave the page.
Export it as an environment variable, replacing the placeholder with your key:
export SPRAG_API_KEY=<your_sprag_api_key>Make a request
Send a clip of the caller's speech as file. The clip ends at the moment you
want judged.
curl https://api.sprag.ai/v1/turns \
-H "Authorization: Bearer $SPRAG_API_KEY" \
-F [email protected] \
-F model=sprag-eotRead the decision
probability is the probability that the caller has finished the turn, from 0
to 1. ended is true when probability reaches eot_threshold.
{
"object": "turn.decision",
"model": "sprag-eot",
"probability": 0.87,
"ended": true,
"eot_threshold": 0.6,
"usage": { "invocations": 1 }
}To act on the decision, read ended. To apply your own threshold, read
probability instead.
Where to go next
API. Look up the request fields, the response, and the
errors for POST /v1/turns.
WebSocket. Stream a caller's audio and look up the session's settings, events, and errors.
Models. See which models detect turns.
To detect turns in a Pipecat pipeline, see Pipecat: turn detection.