I want to convert speech into text in .Net MAUI. I search for same I did not get solution for it.
Please let me know how to implement it.
I follow this link: https://devblogs.microsoft.com/dotnet/speech-recognition-in-dotnet-maui-with-community-toolkit/
Code is as follow:
private async void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
{
CancellationToken cancellationToken = new CancellationToken();
cancellationToken = CancellationToken.None;
var isGranted = await SpeechToText.Default.RequestPermissions(cancellationToken);
if (!isGranted)
{
await Toast.Make("Permission not granted").Show(CancellationToken.None);
return;
}
var recognitionResult = await SpeechToText.Default.ListenAsync(
CultureInfo.GetCultureInfo("uk-ua"),
new Progress(partialText =>
{
RecognitionText += partialText + " ";
}), cancellationToken);
if (recognitionResult.IsSuccessful)
{
string RecognitionText = recognitionResult.Text;
}
else
{
await Toast.Make(recognitionResult.Exception?.Message ?? "Unable to recognize speech").Show(CancellationToken.None);
}
}
Error as in below image
Please share your suggestion, Thanks in advance.
You can check this code in the Microsoft document about SpeechToText.
Here is the code an be used as follows in C#: