waitForAnySpeech

Audio.waitForAnySpeech(timeout, prompt)

Parameters

timeout Time to wait in seconds before stopping waiting for speech.
prompt The text prompt to display to the user while listening for speech

Returns

The phrase heard if the timeout did not occur in a lowercase string.

Description

Suspends execution of the script until any speech is detected in the microphone or a timeout occurs after timeout seconds. If a timeout occurs, the method will return "timeout."

*Note: the returned string is in lowercase

This command uses the entire dictionary of speech recognition words. Generally, using this dictionary size will have a very low recognition quality. This may work okay if you are feeding a chatbot (such as OpenAI or PandoraBot). But, if you are looking for specific phrases, this will most likely not work, and you should use the waitForSpeech() command instead. Using this command for open conversations is discouraged.

Example

// Listen for any response from the user
response = Audio.waitForAnySpeech(30, "Say anything to me");

print("Heard: " + response);