public static void PlaySavedAudioForPreview(string filePath) { SpeechPlayingDialogBox speechPlayingDialog = new SpeechPlayingDialogBox(); WaveOutEvent player = new WaveOutEvent(); player.PlaybackStopped += (s, e) => { try { speechPlayingDialog.Dispatcher.Invoke(() => { speechPlayingDialog.Close(); }); } catch { Logger.Log("Object already disposed."); } }; speechPlayingDialog.Closed += (s, e) => SpeechPlayingDialog_Closed(player); try { using (var reader = new WaveFileReader(filePath)) { player.Init(reader); player.Play(); speechPlayingDialog.ShowDialog(); } } catch { Logger.Log("Audio File not Found"); } }
private static SpeechPlayingDialogBox ShowSpeechCancelDialog(WaveOutEvent player) { SpeechPlayingDialogBox speechPlayingDialog = new SpeechPlayingDialogBox(); speechPlayingDialog.Closed += (sender, e) => SpeechPlayingDialog_Closed(player); speechPlayingDialog.ShowDialog(); return(speechPlayingDialog); }
private static void ShowSpeechCancelDialog(SynthesisState state) { SpeechSynthesizer synthesizer = state.Synthesizer; Prompt spokenPrompt = state.PromptBeingSynthesized; SpeechPlayingDialogBox speechPlayingDialog = new SpeechPlayingDialogBox(state); speechPlayingDialog.Closed += (sender, e) => SpeechPlayingDialog_Closed(synthesizer, spokenPrompt); speechPlayingDialog.ShowDialog(); }
public static void Speak(string text, WatsonVoice voice) { string dirPath = Path.GetTempPath() + AudioService.TempFolderName; string filePath = dirPath + "\\" + string.Format(ELearningLabText.AudioPreviewFileNameFormat, voice.VoiceName); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } SaveStringToWaveFile(text, filePath, voice); SpeechPlayingDialogBox speechPlayingDialog = new SpeechPlayingDialogBox(); WaveOutEvent player = new WaveOutEvent(); player.PlaybackStopped += (s, e) => { try { speechPlayingDialog.Dispatcher.Invoke(() => { speechPlayingDialog.Close(); }); } catch { Logger.Log("Object already disposed"); } }; speechPlayingDialog.Closed += (s, e) => SpeechPlayingDialog_Closed(player); try { using (var reader = new WaveFileReader(filePath)) { player.Init(reader); player.Play(); speechPlayingDialog.ShowDialog(); } } catch { Logger.Log("Audio File not Found"); } }