waitForSpeech
Audio.waitForSpeech(timeout, s1, ...)
Parameters
timeout | Time to wait in seconds before stopping waiting for speech. |
s1... | Strings to wait for that are detected in the microphone. |
Returns
The phrase heard if the timeout did not occur in a lowercase string.Description
Suspends execution of the script until one of the strings specified by s1,.... 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
Example
// Specify the words in the function
response = Audio.waitForSpeech(10, "One", "two", "Three");
print("Heard: " + response);
// Use an array of words to listen for
var words = ["One", "two", "Three"];
response = Audio.waitForSpeech(10, words);
print("Heard: " + response);