private void RefreshVoices(object obj) { GoogleTextToSpeechMgr.GetOnlineVoices(SelectedLanguageCode, true); if (Voices.Count > 0) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Voices))); } }
private void SoundCheckBtnClick(object obj) { if (AudioMgr.UseRecordings) { AudioMgr.PlayAudioClip(Path.Combine(DirectoryMgr.AudioClipsDirectory, @"Sound Files\Sound Check.mp3")); } else { string audioFile = GoogleTextToSpeechMgr.GenerateSpeech("This is a CONVERSE sound level check. " + "Are you able to hear and understand what I am saying, or would you " + "like the volume or speed changed?"); AudioMgr.PlayAudioClip(audioFile); } }
private void GenerateAudioFile(object obj) { bool filePathSet = true; bool fileNameSet = true; bool textSet = true; AudioFileName = Path.GetFileName(AudioFileName); if (String.IsNullOrEmpty(AudioClipText)) { textSet = false; } if (String.IsNullOrEmpty(AudioFileDirectory)) { filePathSet = false; } if (filePathSet && String.IsNullOrEmpty(AudioFileName)) { if (!String.IsNullOrEmpty(AudioClipLabel)) { AudioFileName = AudioClipLabel; } else { filePathSet = false; } } if (!filePathSet || !textSet) { string msg; if (!textSet && !fileNameSet) { msg = "Please complete the directory, filename and audio text fields."; } else if (!textSet) { msg = "Please enter audio text."; } else { msg = "Please complete the directory and filename fields."; } var msgWin = new MessageWin("Generate Audio File", msg); msgWin.Show(); return; } try { Directory.CreateDirectory(AudioFileDirectory); } catch (Exception) { var msgWin = new MessageWin("Generate Audio File", "Please enter a valid directory."); msgWin.Show(); return; } string fileName = Path.Combine(AudioFileDirectory, AudioFileName); if (GoogleTextToSpeechMgr.GenerateAudiofile(AudioClipText, fileName)) { SelectedAudioClip.StateAudioFile = fileName; AudioFileName = Path.GetFileName(fileName); SelectedAudioClip.Label = AudioClipLabel; SelectedAudioClip.StateText = AudioClipText; SelectedAudioClip.ButtonColour = ColourHelper.StatementColour; var messageWin = new MessageWin("Generate Audio clip", String.Format("Audio clip {0} generated", fileName)); messageWin.Show(); Logger.AddLogEntry(LogCategory.INFO, String.Format("Audio clip {0} generated", fileName)); } else { var messageWin = new MessageWin("Generate Audio clips", String.Format("Errors encountered generating \"{0}\" audio clip.", SelectedAudioClip.Label)); messageWin.Show(); Logger.AddLogEntry(LogCategory.ERROR, String.Format("Error generating \"{0}\" audio clip", SelectedAudioClip.Label)); } }