question

MinT-0548 avatar image
0 Votes"
MinT-0548 asked WenyanZhang-MSFT commented

xamarin essentials texttospeech exception handling

im currently using Xamarin.Essentials TextToSpeech in a C# android app.

I've come across a problem I can't quite figure out where the user is using the device as a scanner scanning item barcodes. with each scan, the TTS will say the items description. if the user scans too fast, itll eventually cause an exception . The problem arises when i do catch the exception, we lose the text to speech afterwards unless we restart the app. Is there a way to reset the static class somehow (i doubt it) or is there some way to reset it so that we dont need to restart the whole app to get speech working again?

dotnet-xamarinessentials
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have to say there is no way to reset static class, you may try to add a static method that resets all the variable to defaults, you can refer to this thread https://stackoverflow.com/questions/821151/can-i-reset-a-static-shared-class


0 Votes 0 ·
MinT-0548 avatar image MinT-0548 WenyanZhang-MSFT ·

the thing is im still not sure whats causing the xamarin essentials TextToSpeech class to stop working. that and theres really only 2 methods available to use of that class. is there even a way to wrap a static class to maybe force a way to restart things?

0 Votes 0 ·

From this doc, you could try to use CancellationToken to stop the utterance. In Essentials repo we can see that the tts will shoudown in Dispose method.

0 Votes 0 ·

0 Answers