Timers and timeouts

ASRaaS offers three timers for limiting user silence and recognition time: a no-input timer, a recognition timer, and an end-of-utterance timer. You may optionally set these timers as RecognitionParameters.

No-input timer

By default, the no-input timer starts when recognition starts, but has an infinite timeout, meaning ASRaaS simply waits for the user to speak and never times out:

Default no-input timer

If you set a no-input timeout, for example, no_input_timeout_ms = 3000, the user must start speaking within 3 seconds. If a prompt plays as recognition starts, however, the recognition may time out before the user hears the prompt:

# Set no-input timer to 3 seconds
RecognitionRequest(
    recognition_init_message = RecognitionInitMessage(
        parameters = RecognitionParameters(
            no_input_timeout_ms = 3000
        )
    )
)
# Play prompt to user 

# Send audio
RecognitionRequest(audio)

With these settings, the timer expires before the user speaks:

Timer expires before user speaks

To avoid this problem, use stall_timers and start_timers_message to start the no-input timer only after the prompt finishes:

# Set no-input timer and stall timers
RecognitionRequest(
    recognition_init_message = RecognitionInitMessage(
        parameters = RecognitionParameters(
            no_input_timeout_ms = 3000,
            recognition_flags = RecognitionFlags(stall_timers=True)
        )
    )
)
# Play prompt to user

# Start timers
RecognitionRequest(
    control_message = ControlMessage(
        start_timers_message = StartTimersControlMessage()
    )
)

# Send audio
RecognitionRequest(audio)

Here the timer starts after the prompt, allowing the user time to reply:

Timer starts later

Timeout and timer fields

Field Description
RecognitionParameters
no_input_timeout_ms
(no-input timer)
Time to wait for user input. Default is 0, meaning infinite.

By default, the no-input timer starts with recognition_init_message but is only effective when no_input_timeout_ms has a value.

When stall_timers is True, you can start the timer manually with start_timers_message.

recognition_timeout_ms
(recognition timer)
Duration of recognition, in milliseconds. Default is 0, meaning infinite.

The recognition timer starts when speech input starts (after the no-input timer) but is only effective when recognition_timeout_ms has a value.

utterance_end_silence_ms
(utterance end timer)
Period of time that signals the end of an utterance. Default is 500 (ms, or half a second).

The utterance end timer starts automatically.

RecognitionFlags
stall_timers Do not start the no-input timer. Default is False.

By default, the no-input timer starts with recognition_init_message. When stall_timers is True, this timer does not start at that time.

The other timers are not affected by stall_timers.

ControlMessage
start_timers_message Starts the no-input timer if it was disabled by stall_timers. This message starts the no-input timer manually.

Timeouts and detection modes

In RecognitionParameters, the utterance detection modes do not support all the timeout parameters. In MULTIPLE detection mode, you may not set a recognition timeout, and in DISABLED mode you may not set any timeouts.

Utterance detection mode
Recognition parameter
SINGLE
 
MULTIPLE
 
DISABLED
 
no_input_timeout_ms Supported Supported Not supported
recognition_timeout_ms Supported Not supported Not supported
utterance_end_silence_ms Supported Supported Not supported