You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Xamarin.iOS we found this when we turn on the linker with the following code that the constructor will get linked out and will crash the app:
The lazily-initialized type does not have a public, parameterless constructor.
publicstaticpartialclassTextToSpeech{staticreadonlyLazy<AVSpeechSynthesizer>speechSynthesizer=newLazy<AVSpeechSynthesizer>();internalstaticasyncTaskPlatformSpeakAsync(stringtext,SpeechOptionsoptions,CancellationTokencancelToken=default){using(varspeechUtterance=GetSpeechUtterance(text,options)){awaitSpeakUtterance(speechUtterance,cancelToken);}}staticAVSpeechUtteranceGetSpeechUtterance(stringtext,SpeechOptionsoptions){varspeechUtterance=newAVSpeechUtterance(text);if(options!=null){// null voice if fine - it is the defaultspeechUtterance.Voice=AVSpeechSynthesisVoice.FromLanguage(options.Locale?.Language)??AVSpeechSynthesisVoice.FromLanguage(AVSpeechSynthesisVoice.CurrentLanguageCode);// the platform has a range of 0.5 - 2.0// anything lower than 0.5 is set to 0.5if(options.Pitch.HasValue)speechUtterance.PitchMultiplier=options.Pitch.Value;if(options.Volume.HasValue)speechUtterance.Volume=options.Volume.Value;}returnspeechUtterance;}internalstaticasyncTaskSpeakUtterance(AVSpeechUtterancespeechUtterance,CancellationTokencancelToken){vartcsUtterance=newTaskCompletionSource<bool>();try{speechSynthesizer.Value.DidFinishSpeechUtterance+=OnFinishedSpeechUtterance;speechSynthesizer.Value.SpeakUtterance(speechUtterance);using(cancelToken.Register(TryCancel)){awaittcsUtterance.Task;}}finally{speechSynthesizer.Value.DidFinishSpeechUtterance-=OnFinishedSpeechUtterance;}voidTryCancel(){speechSynthesizer.Value?.StopSpeaking(AVSpeechBoundary.Word);tcsUtterance?.TrySetResult(true);}voidOnFinishedSpeechUtterance(objectsender,AVSpeechSynthesizerUteranceEventArgsargs){if(speechUtterance==args.Utterance)tcsUtterance?.TrySetResult(true);}}}
On Xamarin.iOS we found this when we turn on the linker with the following code that the constructor will get linked out and will crash the app:
From: xamarin/Essentials#1207
The text was updated successfully, but these errors were encountered: