コード例 #1
0
        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");
            }
        }
コード例 #2
0
        private static SpeechPlayingDialogBox ShowSpeechCancelDialog(WaveOutEvent player)
        {
            SpeechPlayingDialogBox speechPlayingDialog = new SpeechPlayingDialogBox();

            speechPlayingDialog.Closed += (sender, e) => SpeechPlayingDialog_Closed(player);
            speechPlayingDialog.ShowDialog();
            return(speechPlayingDialog);
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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");
            }
        }