Ejemplo n.º 1
0
        /// <summary>
        /// Plays the song or sound located at the path's location.
        /// </summary>
        /// <param name="path">The full path of the file to play.</param>
        public void PlayFile(string path)
        {
            bool    isMusic = Path.GetExtension(path) != ".wav";
            IPlayer music;

            try
            {
                try { music = new IrrPlayer(path, isMusic); }
                catch (Exception) { music = new NAudioPlayer(path, isMusic); }
            }
            catch (Exception)
            {
                MessageBox.Show("Audio Player was unable to play the track you selected. The format may not be supported on your system.",
                                "Audio Playback Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            music.Play();
            if (isMusic)
            {
                StopMusic();
                _musicName           = Path.GetFileNameWithoutExtension(path);
                _music               = music;
                trackNameLabel.Text  = @"Now Playing: " + _musicName;
                playTool.Text        = @"Playing";
                playTool.Image       = _playIcons.Images["play"];
                pauseTool.Enabled    = true;
                pauseTool.CheckState = CheckState.Unchecked;
                stopTool.Enabled     = true;
            }
        }
Ejemplo n.º 2
0
 private void RECListBox_DoubleClick(object sender, EventArgs e)
 {
     if (RECListBox.SelectedItem != null)
     {
         string filePath = Path.Combine(outputFolder, (string)RECListBox.SelectedItem);
         audioPlayer.Play(filePath);
     }
 }
Ejemplo n.º 3
0
        private void analyzeButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (RECListBox.SelectedItem != null)
                {
                    string target;
                    try
                    {
                        target = (MainForm.self.RecordingList.WordListBox.SelectedItem as Word).Name;
                    }
                    catch
                    {
                        target = string.Empty;
                    }
                    Dictionary <string, string> result = RecEngine.Recognize(Path.Combine(outputFolder, (string)RECListBox.SelectedItem)).ToDictionary(x => x.Key, x => x.Value);
                    if (result.Count > 0)
                    {
                        NAudioPlayer audioplayer = new NAudioPlayer();
                        audioplayer.Play(Path.Combine(outputFolder, (string)RECListBox.SelectedItem));
                        RecognitionResultMSGBox recMSGBox = new RecognitionResultMSGBox();
                        if (recMSGBox.ShowDialog(result.First().Key, target, result.First().Value) == DialogResult.OK)
                        {
                            scoreBoard.Content.Add(recMSGBox.scoreBoardItem);
                            correctnessLabel.Text = string.Format(@"Correctness: {0:0.0%}", scoreBoard.CalculateCorrectness);
                        }
                        showReportButton.Enabled = true;
                    }
                }
            }
            catch (Exception exp)
            {
#if DEBUG
                MessageBox.Show(exp.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
#endif
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// サウンドを再生する
        /// </summary>
        /// <param name="deviceID">デバイスID</param>
        /// <param name="file">再生するサウンドファイル</param>
        /// <param name="isFileDelete">ファイルを削除するか?</param>
        /// <param name="volume">ボリューム</param>
        private static void PlayCore(
            string deviceID,
            string file,
            bool isFileDelete,
            int volume)
        {
            if (!File.Exists(file))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(deviceID))
            {
                return;
            }

            if (ActGlobals.oFormActMain.InvokeRequired)
            {
                ActGlobals.oFormActMain.Invoke((MethodInvoker) delegate
                {
                    NAudioPlayer.Play(
                        deviceID,
                        file,
                        isFileDelete,
                        volume);
                });
            }
            else
            {
                NAudioPlayer.Play(
                    deviceID,
                    file,
                    isFileDelete,
                    volume);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// テキストを読上げる
        /// </summary>
        /// <param name="textToSpeak">読上げるテキスト</param>
        public void Speak(
            string textToSpeak)
        {
            if (string.IsNullOrWhiteSpace(textToSpeak))
            {
                return;
            }

            Task.Run(() =>
            {
                // ファイルじゃない?
                if (!textToSpeak.EndsWith(".wav"))
                {
                    // 喋って終わる
                    this.SpeakTTS(textToSpeak);

                    return;
                }

                if (File.Exists(textToSpeak))
                {
                    if (TTSYukkuriConfig.Default.EnabledSubDevice)
                    {
                        NAudioPlayer.Play(
                            TTSYukkuriConfig.Default.SubDeviceID,
                            textToSpeak,
                            false,
                            TTSYukkuriConfig.Default.WaveVolume);
                    }

                    NAudioPlayer.Play(
                        TTSYukkuriConfig.Default.MainDeviceID,
                        textToSpeak,
                        false,
                        TTSYukkuriConfig.Default.WaveVolume);
                }
                else
                {
                    // ACTのパスを取得する
                    var baseDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                    var waveDir = Path.Combine(
                        baseDir,
                        @"resources\wav");

                    var wave = Path.Combine(waveDir, textToSpeak);
                    if (File.Exists(wave))
                    {
                        if (TTSYukkuriConfig.Default.EnabledSubDevice)
                        {
                            NAudioPlayer.Play(
                                TTSYukkuriConfig.Default.SubDeviceID,
                                wave,
                                false,
                                TTSYukkuriConfig.Default.WaveVolume);
                        }

                        NAudioPlayer.Play(
                            TTSYukkuriConfig.Default.MainDeviceID,
                            wave,
                            false,
                            TTSYukkuriConfig.Default.WaveVolume);
                    }
                }
            });
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Plays the song or sound located at the path's location.
 /// </summary>
 /// <param name="path">The full path of the file to play.</param>
 public void PlayFile(string path)
 {
     bool isMusic = Path.GetExtension(path) != ".wav";
     IPlayer music;
     try
     {
         try { music = new IrrPlayer(path, isMusic); }
         catch (Exception) { music = new NAudioPlayer(path, isMusic); }
     }
     catch (Exception)
     {
         MessageBox.Show("Sound Test was unable to play the track you selected. The format may not be supported on your system.",
             "Audio Playback Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     music.Play();
     if (isMusic)
     {
         StopMusic();
         _musicName = Path.GetFileNameWithoutExtension(path);
         _music = music;
         trackNameLabel.Text = @"Now Playing: " + _musicName;
         playTool.Text = @"Playing";
         playTool.Image = _playIcons.Images["play"];
         pauseTool.Enabled = true;
         pauseTool.CheckState = CheckState.Unchecked;
         stopTool.Enabled = true;
     }
 }