From 4c6d2563cde3604a2fac6a717150a8c362aa61e0 Mon Sep 17 00:00:00 2001 From: Yan Maniez Date: Sun, 22 Sep 2019 00:21:22 +0200 Subject: [PATCH] =?UTF-8?q?Langue=20parl=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AideDeJeu/AideDeJeu/ViewModels/SpeechViewModel.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/AideDeJeu/AideDeJeu/ViewModels/SpeechViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/SpeechViewModel.cs index ffe29265..d2ba2b44 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/SpeechViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/SpeechViewModel.cs @@ -60,7 +60,18 @@ namespace AideDeJeu.ViewModels _CancellationTokenSource = new CancellationTokenSource(); OnPropertyChanged(nameof(Speaking)); OnPropertyChanged(nameof(NotSpeaking)); - await Xamarin.Essentials.TextToSpeech.SpeakAsync(md, _CancellationTokenSource.Token); + var options = new Xamarin.Essentials.SpeechOptions(); + var locales = (await Xamarin.Essentials.TextToSpeech.GetLocalesAsync()).ToList(); + if (item.Id.Contains("_vo.md")) + { + options.Locale = locales.FirstOrDefault(l => l.Language.StartsWith("en")); + } + else + { + options.Locale = locales.FirstOrDefault(l => l.Language.StartsWith("fr")); + } + + await Xamarin.Essentials.TextToSpeech.SpeakAsync(md, options, _CancellationTokenSource.Token); } catch (Exception ex) {