SpeechRecognizer Component
Properties
language Suggests the language to use for recognizing speech. An empty string (the default) will use the system's default language. Language is specified using a language tag (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) with an optional region suffix, such as en or es-MX. The set of supported languages will vary by device.
Data type: string |
||
Designer Writable | false | |
Code Writeable | true |
speechrecognizerName.language = "" |
Code Readable | true |
let variable = speechrecognizerName.language |
result Returns the last text produced by the recognizer.
Data type: string |
||
Designer Writable | false | |
Code Writeable | false | |
Code Readable | true |
let variable = speechrecognizerName.result |
useLegacy If true, a separate dialog is used to recognize speech (the default). If false, speech is recognized in the background and updates are received as it recognizes words. AfterGettingText may get several calls with partial set to true. Once sufficient time has elapsed since the last utterance, or StopListening is called, the last string will be returned with partial set to false to indicate that it is the final recognized string and no more data will be provided until recognition is again started. See AfterGettingText for more details on partial speech recognition.
Data type: boolean |
||
Designer Writable | true |
<speechrecognizer name="speechrecognizerName" useLegacy="true"> |
Code Writeable | true |
speechrecognizerName.useLegacy = true |
Code Readable | true |
let variable = speechrecognizerName.useLegacy |
class The styling class of the the component
Data type: string |
||
Designer Writable | true |
<speechrecognizer name="speechrecognizerName" class="Test class"> |
Code Writeable | false | |
Code Readable | false |
id The styling id of the the component
Data type: string |
||
Designer Writable | true |
<speechrecognizer name="speechrecognizerName" id="Test id"> |
Code Writeable | false | |
Code Readable | false |
name The name of the component that will be used to refer to it in code.
Data type: string |
||
Designer Writable | true |
<speechrecognizer name="speechrecognizerName" name="testComponent"> |
Code Writeable | false | |
Code Readable | false |
Methods
Method name | Description | Parameters | ||||
---|---|---|---|---|---|---|
getText |
Asks the user to speak, and converts the speech to text. Signals the AfterGettingText event when the result is available. speechrecognizerName.getText() |
|
||||
stop |
Function used to forcefully stop listening speech in cases where SpeechRecognizer cannot stop automatically. This function works only when the UseLegacy property is set to false. speechrecognizerName.stop() |
|
||||
addEventListener |
Method used to create event listeners. See Events below for samples. |
|
Events
Event name | Description | Parameters | ||||
---|---|---|---|---|---|---|
afterGettingText | Simple event to raise after the SpeechRecognizer has recognized speech. If UseLegacy is true, then this event will only happen once at the very end of the recognition. If UseLegacy is false, then this event will run multiple times as the SpeechRecognizer incrementally recognizes speech. In this case, partial will be true until the recognized speech has been finalized (e.g., the user has stopped speaking), in which case partial will be false.speechrecognizerName.addEventListener( "afterGettingText", function (result, partial) { //Your code here } ) |
|
||||
beforeGettingText | Simple event to raise when the SpeechRecognizer is invoked but before its activity is started.speechrecognizerName.addEventListener( "beforeGettingText", function () { //Your code here } ) |
|