protected void AddVoice() { Window window = win as Window; if (answer.Voice.Length > 1) { AddVoiceBord(); } else { try { VoiceAPI voice = new VoiceAPI(); answer.Voice = voice.UploadVoice(answer.Word); if (answer.Voice.Length > 1) { AddVoiceBord(); } } catch { } //TODO:maybe I need to wrote some message } MediaElement media = CreateMediElement(window.FindResource("MediaStyle") as Style); media.Volume = 1; Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(window, "DataGrid"); grid.Children.Add(media); SetVoice(); }
//якщо для аудіювання не знайдено 5 озвучених слів завантажується озвучування List <WordModel> UploadVoice(List <WordModel> list) { VoiceAPI api = new VoiceAPI(); for (int i = list.Count - 1; i >= 0; i--) { if (list[i].Voice.Length <= 1) { byte[] voice = api.UploadVoice(list[i].Word); list[i].Voice = voice; if (list[i].Voice.Length <= 1) { list.Remove(list[i]); } } } return(list); }