ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Speech Recognition functions
  • Special cases
  • Application in the background: Specific case from Android 10
  • Required permissions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Triggers the device's speech recognition service.
Remark: This function can be used in the emulator. This function cannot be used in the simulator.
Example
// Display the propositions returned by the speech recognition service in a List Box control
MyList is string
MyList = SpeechRecognitionTrigger("I am listening...")
IF ErrorOccurred = False THEN
FOR EACH STRING Proposition OF MyList SEPARATED BY CR
ListAdd(LIST_ListProposition, Proposition)
END
END
Syntax

Triggering the speech recognition service (synchronous mode) Hide the details

<Result> = SpeechRecognitionTrigger([<Text>])
<Result>: Character string
  • List of words or sentences proposed by the speech recognition service based on the words pronounced by the user. Each proposition is separated by a CR character (Carriage Return).
  • Empty string ("") in the following cases:
    • if the speech recognition was canceled by the user.
    • if an error occurred.
    • if no match was found by the speech recognition service.
    In this case, the ErrorOccurred variable is set to True. To get more details on the error, use ErrorInfo.
<Text>: Optional character string
Text that will appear in the window displayed by the speech recognition service. This window blocks the application.
iPhone/iPadMac Catalyst

Triggering the speech recognition service (asynchronous mode) Hide the details

SpeechRecognitionTrigger([<Text>, ] <WLanguage procedure>)
<Text>: Optional character string
Text that will appear in the window displayed by the speech recognition service. This window does not block the application.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called to run speech recognition. This procedure is used to get the proposed words or sentences. For more details on this procedure, see Parameters of the procedure used by SpeechRecognitionTrigger.
Remarks

Special cases

  • SpeechRecognitionTrigger uses the device's speech recognition service. The function will fail if this service is not available.
  • When speech recognition is triggered, a window is opened to notify the user of the start and end of the speech recognition session as well as the progress of the process.
    • Syntax 1: SpeechRecognitionTrigger blocks the application as long as this window is displayed.
    • iPhone/iPadMac Catalyst Syntax 2: SpeechRecognitionTrigger does not block the application as long as this window is displayed. Propositions are processed in a WLanguage procedure.
  • If one of the propositions returned by the speech recognition service corresponds to a command added to the current window by SpeechRecognitionAddCommand, the WLanguage procedure corresponding to this command will be executed.
  • Caution: SpeechRecognitionTrigger requires an Internet connection and therefore cannot be used in offline mode.
  • iPhone/iPad This function can be used from iOS 10.
AndroidAndroid Widget

Application in the background: Specific case from Android 10

From Android 10, it is no longer possible to open a window when the application is in the background.
SpeechRecognitionTrigger can open a window. If this function is used while the application is in the background, a fatal error will occur.
Tips:
  • It is possible to determine if the application is in the background using InBackgroundMode.
  • If an application needs to interact with the user while it is in the background, the solution is to display a notification (via the Notification type). The application will be brought back to the foreground when the notification is clicked, if the ActivateApplication property is set to True. You can also open a window from the procedure passed to the ActionClick property.
AndroidAndroid Widget

Required permissions

The call to this function modifies the permissions required by the application.
Required permission: INTERNET: this permission allows the applications to open the network sockets.
Related Examples:
Android Speech Synthesis Android (WINDEV Mobile): Android Speech Synthesis
[ + ] This educational example explains how to manage the recognition and the speech synthesis Android.
The speech synthesis is performed by using either the WLanguage functions, or an external JAR file included in the WINDEV Mobile project.
Business / UI classification: UI Code
Component: wd290android.aar
Minimum version required
  • Version 17
Comments
Click [Add] to post a comment

Last update: 11/20/2023

Send a report | Local help