public AppShell() { InitializeComponent(); Routing.RegisterRoute(nameof(ItemDetailPage), typeof(ItemDetailPage)); Routing.RegisterRoute(nameof(NewItemPage), typeof(NewItemPage)); Routing.RegisterRoute(nameof(WordsUnitDetailPage), typeof(WordsUnitDetailPage)); Routing.RegisterRoute(nameof(WordsUnitBatchEditPage), typeof(WordsUnitBatchEditPage)); Routing.RegisterRoute(nameof(WordsTextbookDetailPage), typeof(WordsTextbookDetailPage)); Routing.RegisterRoute(nameof(WordsLangDetailPage), typeof(WordsLangDetailPage)); Routing.RegisterRoute(nameof(WordsDictPage), typeof(WordsDictPage)); Routing.RegisterRoute(nameof(PhrasesUnitDetailPage), typeof(PhrasesUnitDetailPage)); Routing.RegisterRoute(nameof(PhrasesUnitBatchEditPage), typeof(PhrasesUnitBatchEditPage)); Routing.RegisterRoute(nameof(PhrasesTextbookDetailPage), typeof(PhrasesTextbookDetailPage)); Routing.RegisterRoute(nameof(PhrasesLangDetailPage), typeof(PhrasesLangDetailPage)); Routing.RegisterRoute(nameof(PatternsDetailPage), typeof(PatternsDetailPage)); Routing.RegisterRoute(nameof(PatternsWebPagesListPage), typeof(PatternsWebPagesListPage)); Routing.RegisterRoute(nameof(PatternsWebPagesDetailPage), typeof(PatternsWebPagesDetailPage)); Routing.RegisterRoute(nameof(PatternsWebPagesBrowsePage), typeof(PatternsWebPagesBrowsePage)); Routing.RegisterRoute(nameof(ReviewOptionsPage), typeof(ReviewOptionsPage)); Task.Run(async() => { SpeechLocales = (await TextToSpeech.GetLocalesAsync()).ToList(); }); }
public TextToSpeechViewModel() { tts = new TextToSpeechModel() { Volume = .75f, Pitch = 1.0f }; SpeakCommand = new Command(async() => { try { var locales = await TextToSpeech.GetLocalesAsync(); var locale = locales.FirstOrDefault(); var settings = new SpeechOptions() { Pitch = Pitch, Volume = Volume, Locale = locale }; await TextToSpeech.SpeakAsync(Text, settings); } catch (Exception ex) { } }); }
private async void OnReadDescription(object obj) { if (SelectedRecipeDescription != string.Empty) { try { var locales = await TextToSpeech.GetLocalesAsync(); Locale locale = (Locale)locales.ElementAt(50); if (SelectedRecipeDescription != string.Empty) { await TextToSpeech.SpeakAsync(SelectedRecipeDescription, new SpeechOptions() { Locale = locale }); } } catch (Exception) { isMessageVisible = true; CannotReadText = MessageNames.CannotReadDescription; } } else { await _dialogService.ShowDialog(MessageNames.RecipeHasNoDescription, "Failure", "Ok"); } }
private async void PlayTTSCommandExecute() { try { var locales = await TextToSpeech.GetLocalesAsync(); // Grab the first locale var locale = locales.Where(x => x.Country == "FR").FirstOrDefault(); if (locale == null) { locale = locales.FirstOrDefault(); } var settings = new SpeechOptions() { Volume = 1.0f, Pitch = 1.2f, Locale = locale }; await TextToSpeech.SpeakAsync(CurrentSample.Title, settings); Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("File", CurrentSample.File); Analytics.TrackEvent("TTSSpokenMP3", dict); } catch (Exception ex) { Crashes.TrackError(ex); } }
public async Task SpeakNow() { cts = new CancellationTokenSource(); var locales = await TextToSpeech.GetLocalesAsync(); if (locales != null) { // Grab the first locale var locale = locales.Where(x => x.Language == "en").FirstOrDefault(); var settings = new SpeechOptions() { Volume = (float)0.85, Pitch = (float)1.0, Locale = locale }; if (!string.IsNullOrEmpty(NotesDescription) && !string.IsNullOrWhiteSpace(NotesDescription)) { await TextToSpeech.SpeakAsync(NotesDescription, settings, cancelToken : cts.Token); } else { DependencyService.Get <IToast>().Show("Text is Empty"); } } }
protected override async void OnCreate(Bundle savedInstanceState) { var themeId = Preferences.Get("theme", 0); if (themeId > 0) { SetTheme(themeId); } base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_select_voice); locales = await TextToSpeech.GetLocalesAsync(); adapter = new LocalesAdapter(locales); adapter.ItemClick += Adapter_ItemClick; recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); var layoutManager = new LinearLayoutManager(this); recyclerView.SetLayoutManager(layoutManager); recyclerView.SetAdapter(adapter); }
public async Task SpeakNowDefaultSettings(string text) { cts = new CancellationTokenSource(); var locales = await TextToSpeech.GetLocalesAsync(); // Grab the first locale var locale = locales.FirstOrDefault(); var settings = new SpeechOptions() { Locale = locale }; try { await TextToSpeech.SpeakAsync(text, settings, cancelToken : cts.Token); isSpeaking = true; } catch (Exception) { // throw; } // This method will block until utterance finishes. }
private void ResetBtn_Clicked(object sender, EventArgs e) { points = 0; collection = new ObservableCollection <Word>(App.Database.GetWords()); Sessioncollection = new ObservableCollection <Word>(App.Database.GetWords()); ActualField.Text = isEnglish == false ? Sessioncollection[0].RussianWord : Sessioncollection[0].EnglishWord; answerFld.Text = ""; var tgr = new TapGestureRecognizer(); tgr.Tapped += async(s, ev) => { var locales = await TextToSpeech.GetLocalesAsync(); SpeechOptions so; if (isEnglish) { so = new SpeechOptions { Locale = locales.FirstOrDefault(l => l.Country == "US") }; } else { so = new SpeechOptions { Locale = locales.FirstOrDefault(l => l.Country == "RU") }; } await TextToSpeech.SpeakAsync(ActualField.Text, so); }; ActualField.GestureRecognizers.Add(tgr); }
public TextoVozViewModel() { textoVoz = new TextoVoz() { Volumen = .75f, Pitch = 1.0f }; HablaCommand = new Command(async() => { try { var locales = await TextToSpeech.GetLocalesAsync(); var locale = locales.FirstOrDefault(); var settings = new SpeakSettings() { Pitch = Pitch, Volume = Volumen, Locale = locale }; await TextToSpeech.SpeakAsync(Texto, settings); } catch (Exception ex) { } }); }
public TextToSpeechCalc() { Task.Run(() => { localePicked = TextToSpeech.GetLocalesAsync().Result.FirstOrDefault(); }); }
private static async Task <Locale?> GetLocaleForLanguage(string language) { var supportedLocales = await TextToSpeech.GetLocalesAsync(); var matchingLocales = supportedLocales.Where(loc => loc.Language?.StartsWith(language) == true).ToList(); if (!matchingLocales.Any()) { return(null); } var matchingCountry = matchingLocales.FirstOrDefault(loc => loc.Country?.ToLowerInvariant() == language); if (matchingCountry.Language != null) { return(matchingCountry); } var matchingCountryCode = matchingLocales.FirstOrDefault(loc => { var split = loc.Language.Split('-'); return(split.Length > 1 && split[1]?.ToLowerInvariant() == language); }); if (matchingCountryCode.Language != null) { return(matchingCountryCode); } return(matchingLocales.First()); }
// ============================================================================ // Voice Announcement at start of each function // // Values: // Pitch 0 to 2.0 // Volume 0 to 1.0 // // Preferences.Set("SpeechPitch", "50"); // Preferences.Set("SpeechVolume", "100"); // ============================================================================ public static async Task CCAnnounce(string anc) { // // Set Volume input 0 - 100, output 0.0 1.0 // int temp1 = Convert.ToInt32(Preferences.Get("SpeechVolume", "default_value")); // 100 float temp2 = temp1 / 100.0f; // 1 string temp3 = Convert.ToString(temp2); float Vol1 = float.Parse(temp3, CultureInfo.InvariantCulture.NumberFormat); // // Set Pitch input 0 100, output 0. 2.0 // int temp10 = Convert.ToInt32(Preferences.Get("SpeechPitch", "default_value")); // 100 float temp12 = (temp10 / 100.0f) * 2f; // 1 string temp13 = Convert.ToString(temp12); float Pit1 = float.Parse(temp13, CultureInfo.InvariantCulture.NumberFormat); { if (anc.Length > 0) { var locales = await TextToSpeech.GetLocalesAsync(); var locale = locales.FirstOrDefault(); var settings = new SpeechOptions() { Volume = Vol1, //1.0f, // .75f, Pitch = Pit1, Locale = locale }; //grb//await TextToSpeech.SpeakAsync("Volume, Pitch, Locale", settings); } } }
private async void SpeakRuBtn_Clicked(object sender, EventArgs e) { var locales = await TextToSpeech.GetLocalesAsync(); var settings = new SpeechOptions { Locale = locales.FirstOrDefault(l => l.Country == "RU") }; await TextToSpeech.SpeakAsync(RussianWord.Text, settings); }
private async void GetLanguages() { IEnumerable <Locale> locales = await TextToSpeech.GetLocalesAsync(); foreach (Locale locale in locales) { Language lang = new Language(locale.Name, locale.Language); Languages.Add(lang); } }
private async void Button_Clicked(object sender, EventArgs e) { var locales = await TextToSpeech.GetLocalesAsync(); var german = locales.FirstOrDefault(l => l.Language.Equals("ita", StringComparison.InvariantCultureIgnoreCase)); await TextToSpeech.SpeakAsync("Papa ist ein geiler Typ", new SpeechOptions { Locale = german ?? locales.FirstOrDefault() }); }
private void GetLocalesAsync() { Task.Run(async() => { var locales = await TextToSpeech.GetLocalesAsync(); Locales = new LocalesData { Id = nameof(Locales), Value = locales, Parent = this, TimeStamp = DateTime.UtcNow }; }); }
async Task OnPickLocale() { var locales = await TextToSpeech.GetLocalesAsync(); var names = locales.Select(i => i.Name).ToArray(); var result = await Application.Current.MainPage.DisplayActionSheet("Pick", "OK", null, names); selectedLocale = locales.FirstOrDefault(i => i.Name == result); Locale = (result == "OK" || string.IsNullOrEmpty(result)) ? "Default" : result; }
async void SpeakButton_Clicked(object sender, EventArgs e) { var locales = await TextToSpeech.GetLocalesAsync(); var locale = locales.FirstOrDefault(l => l.Language == "en" && l.Country == "US"); var option = new SpeechOptions { Locale = locale }; await TextToSpeech.SpeakAsync(textEditor.Text, option); }
public async Task SpeakNowDefaultSettings4() { var locales = await TextToSpeech.GetLocalesAsync(); var locale = locales.FirstOrDefault(x => x.Language == "es"); var settings = new SpeechOptions() { Locale = locale }; await TextToSpeech.SpeakAsync("no"); }
private async void Button_Clicked(object sender, System.EventArgs e) { var model = (ItemDetailViewModel)BindingContext; var locales = await TextToSpeech.GetLocalesAsync(); var german = locales.FirstOrDefault(l => l.Name.Equals(model.Text, StringComparison.InvariantCultureIgnoreCase)); await TextToSpeech.SpeakAsync("Papa ist ein geiler Typ", new SpeechOptions { Locale = german ?? locales.FirstOrDefault() }); }
async void btnFalar_ExecutarLocalidades(System.Object sender, System.EventArgs e) { var localidades = await TextToSpeech.GetLocalesAsync(); var localidade = localidades.FirstOrDefault(); var settings = new SpeechOptions() { Locale = localidade }; await TextToSpeech.SpeakAsync(entryTexto.Text, settings); }
private static async Task Speak(String message, LanguageInfo locale) { var locales = await TextToSpeech.GetLocalesAsync(); var settings = new SpeechOptions() { Volume = .75f, Pitch = 1.0f, Locale = locales.FirstOrDefault(item => item.Language == locale.Key) }; await TextToSpeech.SpeakAsync(message, settings); }
private static async Task <SpeechOptions> GetSpeechOptions() { var locales = await TextToSpeech.GetLocalesAsync(); var defaultLocale = GetDefaultLanguage(locales); var selectedLocale = GetSelectedLanguageOrDefault(locales, defaultLocale); var settings = new SpeechOptions() { Locale = selectedLocale, }; return(settings); }
/// <summary> /// 大聲朗讀 /// </summary> public async Task SpeakNow(string content) { var locales = await TextToSpeech.GetLocalesAsync(); var locale = locales.Where(l => l.Language == "zh-TW").First(); var settings = new SpeechOptions() { Volume = (float?)1.0, Pitch = (float?)1.0, Locale = locale }; await TextToSpeech.SpeakAsync(content, settings); }
async void OnHearItClicked(System.Object sender, System.EventArgs e) { var locales = await TextToSpeech.GetLocalesAsync(); var locale = locales.FirstOrDefault(l => l.Language == MainPage.player.Language); var settings = new SpeechOptions() { Volume = 1.0f, Pitch = 1.0f, Locale = locale }; await TextToSpeech.SpeakAsync(Story, settings); }
public async Task <IEnumerable <Item> > GetItemsAsync(bool forceRefresh = false) { var locales = await TextToSpeech.GetLocalesAsync(); items.Clear(); items.AddRange(locales.Select(i => new Item { Id = Guid.NewGuid().ToString(), Text = i.Name, Description = i.Language, })); return(await Task.FromResult(items)); }
private async Task InitSpeak() { var locales = await TextToSpeech.GetLocalesAsync(); // Grab the first locale var locale = locales.Where(o => o.Language.ToLower() == "fr").FirstOrDefault(); speechOptions = new SpeechOptions() { Volume = .75f, Pitch = 0.1f, Locale = locale }; }
private async Task SayTitle() { var languages = await TextToSpeech.GetLocalesAsync(); var locale = languages.GetEnumerator().Current; var settings = new SpeechOptions() { Volume = 1, Pitch = 1, Locale = locale }; await TextToSpeech.SpeakAsync(_sound.Title, settings); }
/// <summary> /// Озвучить результат на английском /// </summary> /// <param name="text"></param> /// <returns></returns> public static async Task <string> VoiceResultInEnglish(string text) { ctsEng = new CancellationTokenSource(); var locales = await TextToSpeech.GetLocalesAsync(); var settings = new SpeechOptions() { Volume = 1, Locale = locales.Where(x => x.Language == "en").First(), Pitch = 1, }; await TextToSpeech.SpeakAsync(text, settings, cancelToken : ctsEng.Token); return(locales.ToString()); }
public async Task SpeakNowDefaultSettings() { string message = this.Message; var locales = await TextToSpeech.GetLocalesAsync(); // Grab the first locale var locale = locales.FirstOrDefault(x => x.Language == "es"); var settings = new SpeechOptions() { Locale = locale }; await TextToSpeech.SpeakAsync(message); }