예제 #1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            string          soundName     = soundNameTextBox.Text;
            List <WAVSound> soundList     = new List <WAVSound>();
            List <string>   selectedFiles = new List <string>();

            foreach (int checkedIndex in soundListListView.CheckedIndices)
            {
                selectedFiles.Add(files[checkedIndex]);
            }
            foreach (string file in selectedFiles)
            {
                WAVSound sound = new WAVSound();
                sound.LoadFromFile(file);
                soundList.Add(sound);
            }
            if (recognizer.ContainsSound(soundName))
            {
                if (MessageBox.Show("Overwrite existing instance?", "Sound available", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    recognizer.RemoveSound(soundName);
                    recognizer.AppendSound(soundName, soundList);
                }
            }
            else
            {
                recognizer.AppendSound(soundName, soundList);
            }
        }
        private void speakButton_Click(object sender, EventArgs e)
        {
            string sentence = sentenceTextBox.Text;

            if (sentence != "")
            {
                speechVisualizer.MarkerList = new List <SoundMarker>();
                speechVisualizer.SetPitchPeriodSpecification(null);

                string voiceName = voiceSelectionComboBox.SelectedItem.ToString();
                speechSynthesizer.SetOutputToWaveFile("./tmpOutput.wav", new SpeechAudioFormatInfo(16000, AudioBitsPerSample.Sixteen, AudioChannel.Mono));
                speechSynthesizer.Speak(sentence);
                speechSynthesizer.SetOutputToDefaultAudioDevice();
                speechSynthesizer.SelectVoice(voiceName);
                speechSynthesizer.Speak(sentence);
                currentSound = new WAVSound();
                currentSound.LoadFromFile("./tmpOutput.wav");

                double startTime = currentSound.GetFirstTimeAboveThreshold(0, 10, 20);
                double endTime   = currentSound.GetLastTimeAboveThreshold(0, 10, 20);
                currentSound = currentSound.Extract(startTime, endTime);
                speechVisualizer.SetRange(0, currentSound.GetDuration(), -32768, 32768);
                speechVisualizer.SetSound(currentSound);
                speechVisualizer.Invalidate();

                soundTypeIdentificationButton.Enabled = true;
                playSoundButton.Enabled            = true;
                modifySoundButton.Enabled          = true;
                saveSoundToolStripMenuItem.Enabled = true;
            }
        }
예제 #3
0
        /// <summary>
        /// Imports all sounds in a folder and treats them as unkown.
        /// </summary>
        /// <param name="folder">The folder path.</param>
        public void importUnknownSounds(string folder)
        {
            string[] filePaths = Directory.GetFiles(folder);
            unknownSoundList.Capacity = (filePaths.Length);

            foreach (string path in filePaths)
            {
                WAVSound sound = new WAVSound();
                sound.LoadFromFile(path);
                sound.Name = "UNKNOWN";
                unknownSoundList.Add(sound);
            }
            Console.WriteLine("unknownSoundList = " + unknownSoundList.Count);
        }
        private void loadToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "WAV files (*.wav)|*.wav";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                testSound = new WAVSound();
                testSound.LoadFromFile(openFileDialog.FileName);
                soundVisualizer.SetSound(testSound);
                playSoundButton.Enabled            = true;
                saveSoundToolStripMenuItem.Enabled = true;
            }
        }
 private void loadSoundToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog openFileDialog = new OpenFileDialog())
     {
         openFileDialog.Filter = "WAV files (*.wav)|*.wav";
         if (openFileDialog.ShowDialog() == DialogResult.OK)
         {
             WAVSound sound = new WAVSound();
             sound.LoadFromFile(openFileDialog.FileName);
             soundVisualizer.SetSound(sound);
             saveSoundToolStripMenuItem.Enabled = true;
             raiseVolumeButton.Enabled          = true;
             reduceVolumeButton.Enabled         = true;
             playButton.Enabled      = true;
             filterToolStrip.Enabled = true;
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Import all sounds from the subfolders of a folder (given as parameter). Assumes that test sounds are placed
        /// in folders with the same name as those found in IsolatedWordRecognizer.GetAvailableSounds().
        /// </summary>
        /// <param name="folder">The root folder for the test sounds.</param>
        public void importTestSounds(string folder)
        {
            recognizerSounds = recognizer.GetAvailableSounds();

            for (int i = 0; i < recognizerSounds.Count; i++)
            {
                string[]        filePaths = Directory.GetFiles(folder + "\\" + recognizerSounds[i]);
                List <WAVSound> soundList = new List <WAVSound>(filePaths.Length);

                foreach (string path in filePaths)
                {
                    WAVSound sound = new WAVSound();
                    sound.LoadFromFile(path);
                    sound.Name = recognizerSounds[i];
                    soundList.Add(sound);
                }
                Console.WriteLine("samples = " + soundList.Count);
                testSound.Add(soundList);
            }

            Console.WriteLine("numWords = " + testSound.Count);
        }