.NET MAUI SpeechToTextButton WinUI Support Specifics
The Telerik UI for .NET MAUI SpeechToTextButton control is designed to work seamlessly across all supported platforms, including WinUI.
The Speech Recognizer uses platform-specific speech recognition services. By default, the RadSpeechToTextButton
control uses the RadSpeechRecognizer
as a speech recognizer creator.
On WinUI, the RadSpeechRecognizer
is not set to the RadSpeechToTextButton
. When you click the control, an InvalidOperationException
is thrown. The reason behind this is a limitation in the WinUI platform speech recognition service—Windows.Media.SpeechRecognition
.
The RadSpeechRecognizer
on WinUI utilizes the Windows.Media.SpeechRecognition
. There are specific considerations when using the control on WinUI due to limitations in the Windows.Media.SpeechRecognition
API. The app crashes when trying to close the application via the "X" button and the app is Packaged.
See the following bug report for more details: Application crashes after using SpeechRecognizer in a Packaged App.
Solutions
To use the SpeechToTextButton on WinUI, you can use one of the following approaches described in the table below:
Packaged Apps | Unpackaged Apps |
---|---|
Create a custom recognizer | Create a custom recognizer |
Use the RadSpeechRecognizer
|
If you want to use the RadSpeechRecognizer
on WinUI, set the SpeechRecognizerCreator
property of the RadSpeechToTextButton
to RadSpeechRecognizer
:
this.speechToTextButton.SpeechRecognizerCreator = () => new RadSpeechRecognizer();
Configure Speech Recognition
Confirm the following are enabled in your WinUI app:
- Online speech recognition—(Settings -> Privacy -> Privacy & Security) is enabled.
- Microphone—(Settings -> Privacy & Security -> Microphone) has the necessary permissions for the app.
Language Support
When setting the RadSpeechToTextButton.LanguageTag
property to a specific value, ensure that the language is supported by the Windows.Media.SpeechRecognition.SpeechRecognizer
on WinUI.
For more details, review the Microsoft documentation.