private void RecognitionLoop(WAVSound soundToRecognize) { // Monitor.Enter(recognitionLockObject); try { soundToRecognize.GenerateMemoryStream(); speechRecognitionEngine.SetInputToWaveStream(soundToRecognize.WAVMemoryStream); RecognitionResult r = speechRecognitionEngine.Recognize(); if (r != null) { OnSoundRecognized(r); } if (extractDetectedSounds) { OnSoundDetected(soundToRecognize.Copy()); } recognizerBusy = false; } catch { // Nothing to do here - try-catch needed to avoid (rare) crashes when the WAVE stream cannot be found. } finally { recognizerBusy = false; // Needed if the catch is triggered. } // Monitor.Exit(recognitionLockObject); }
private void speakSentenceButton_Click(object sender, EventArgs e) { speechSynthesizer.Volume = double.Parse(volumeTextBox.Text); string wordString = sentenceToSpeakTextBox.Text; if (wordString != "") { List <string> wordList = wordString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); List <double> silenceList = new List <double>() { }; for (int ii = 0; ii < (wordList.Count - 1); ii++) { silenceList.Add(0.05); } WAVSound sentenceSound = speechSynthesizer.GenerateWordSequence(wordList, silenceList); SoundPlayer soundPlayer = new SoundPlayer(); sentenceSound.GenerateMemoryStream(); sentenceSound.WAVMemoryStream.Position = 0; // Manually rewind stream soundPlayer.Stream = null; soundPlayer.Stream = sentenceSound.WAVMemoryStream; soundPlayer.PlaySync(); sentenceSpeechVisualizer.SetSound(sentenceSound); } }
private void SpeakSentence(object sender, EventArgs e) { if (sentenceBox.Items.Count == 0) { return; } List <string> wordList = new List <string>(sentenceBox.Items.Count); List <double> silenceList = new List <double>(sentenceBox.Items.Count); foreach (var v in sentenceBox.Items) { string word = v as string; wordList.Add(word); silenceList.Add(0.5); } WAVSound sentence = _synthesizer.GenerateWordSequence(wordList, silenceList); SoundPlayer soundPlayer = new SoundPlayer(); sentence.GenerateMemoryStream(); sentence.WAVMemoryStream.Position = 0; // Manually rewind stream soundPlayer.Stream = null; //TODO varför? soundPlayer.Stream = sentence.WAVMemoryStream; soundPlayer.Play(); }
private void editorPlayButton_Click(object sender, EventArgs e) { saveSoundToolStripMenuItem.Enabled = true; editorFormantSpecification.FundamentalFrequency = speechSynthesizer.FundamentalFrequency; editorFormantSpecification.SamplingFrequency = speechSynthesizer.SamplingFrequency; editorFormantSpecification.GenerateSettingsSequence(); speechSynthesizer.StorePitch = true; WAVSound sound = speechSynthesizer.GenerateSound(editorFormantSpecification); // List<double> pitchList = speechSynthesizer.PitchList; // augmentedSoundVisualizer.SetSound(sound, pitchList); int selectedIndex = formantSpecificationListBox.SelectedIndex; editorSpeechVisualizer.SetSound(sound); List <List <double> > timePitchPeriodList = speechSynthesizer.TimePitchPeriodList; editorSpeechVisualizer.SetTimePitchPeriodList(timePitchPeriodList); ShowFormantSpecification(selectedIndex); SoundPlayer soundPlayer = new SoundPlayer(); sound.GenerateMemoryStream(); sound.WAVMemoryStream.Position = 0; // Manually rewind stream soundPlayer.Stream = null; soundPlayer.Stream = sound.WAVMemoryStream; soundPlayer.PlaySync(); }
private void modifySoundButton_Click(object sender, EventArgs e) { speechVisualizer.MarkerList = new List <SoundMarker>(); speechModifier.TopFraction = double.Parse(topFractionTextBox.Text); double relativeStartPitch = double.Parse(relativeStartPitchTextBox.Text); double relativeEndPitch = double.Parse(relativeEndPitchTextBox.Text); Boolean adjustDuration = Boolean.Parse(adjustDurationComboBox.SelectedItem.ToString()); double relativeDuration = double.Parse(relativeDurationTextBox.Text); // Only relevant if adjustDuration = true. WAVSound modifiedSound = speechModifier.Modify(currentSound, relativeStartPitch, relativeEndPitch, adjustDuration, relativeDuration); // modifiedSound.MedianFilter(5); // modifiedSound.LowPassFilter(1500); // modifiedSound.SetMaximumNonClippingVolume(); // modifiedSound.SetMaximumNonClippingVolume(); SoundPlayer soundPlayer = new SoundPlayer(); modifiedSound.GenerateMemoryStream(); modifiedSound.WAVMemoryStream.Position = 0; // Manually rewind stream soundPlayer.Stream = null; soundPlayer.Stream = modifiedSound.WAVMemoryStream; soundPlayer.PlaySync(); speechVisualizer.SetRange(0, modifiedSound.GetDuration(), -32768, 32768); speechVisualizer.SetPitchPeriodSpecification(null); speechVisualizer.SetSound(modifiedSound); currentSound = modifiedSound.Copy(); soundTypeIdentificationButton.Enabled = true; findPitchPeriodsButton.Enabled = false; findPitchMarksButton.Enabled = false; }
private void playButton_Click(object sender, EventArgs e) { SoundPlayer soundPlayer = new SoundPlayer(); WAVSound sound = soundVisualizer.Sound.Copy(); sound.GenerateMemoryStream(); sound.WAVMemoryStream.Position = 0; // Manually rewind stream soundPlayer.Stream = null; soundPlayer.Stream = sound.WAVMemoryStream; soundPlayer.PlaySync(); }
private void playSoundButton_Click(object sender, EventArgs e) { playSoundButton.Enabled = false; WAVSound sound = soundVisualizer.Sound.Copy(); // recorderVisualizer.Sound.Copy(); SoundPlayer soundPlayer = new SoundPlayer(); sound.GenerateMemoryStream(); sound.WAVMemoryStream.Position = 0; // Manually rewind stream soundPlayer.Stream = null; soundPlayer.Stream = sound.WAVMemoryStream; soundPlayer.PlaySync(); playSoundButton.Enabled = true; }
private void SingleWord(object sender, EventArgs e) { var word = wordBox.SelectedItem; if (word != null) { WAVSound sound = _synthesizer.GenerateWord((string)word); SoundPlayer soundPlayer = new SoundPlayer(); sound.GenerateMemoryStream(); sound.WAVMemoryStream.Position = 0; // Manually rewind stream soundPlayer.Stream = null; soundPlayer.Stream = sound.WAVMemoryStream; soundPlayer.PlaySync(); } }
private void HandlePanelMouseClick(object sender, MouseEventArgs e) { SoundPlayer soundPlayer = new SoundPlayer(); WAVSound sound = ((SoundVisualizer)sender).Sound; string tagString = (string)((SoundVisualizer)sender).Tag; string[] tagStringSplit = tagString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int xIndex = int.Parse(tagStringSplit[0]); int yIndex = int.Parse(tagStringSplit[1]); OnItemClicked(xIndex, yIndex); sound.GenerateMemoryStream(); sound.WAVMemoryStream.Position = 0; // Manually rewind stream soundPlayer.Stream = null; soundPlayer.Stream = sound.WAVMemoryStream; soundPlayer.PlaySync(); }
private void synthesizerSpecificationListBox_SelectedIndexChanged(object sender, EventArgs e) { int selectedSpecificationIndex = synthesizerSpecificationListBox.SelectedIndex; if (selectedSpecificationIndex >= 0) { editorFormantSpecification = speechSynthesizer.SpecificationList[selectedSpecificationIndex].Copy(); ShowFormantSpecification(0); editorFormantSpecification.GenerateSettingsSequence(); WAVSound sound = speechSynthesizer.GenerateSound(editorFormantSpecification); editorSpeechVisualizer.SetSound(sound); editorPlayButton.Enabled = true; SoundPlayer soundPlayer = new SoundPlayer(); sound.GenerateMemoryStream(); sound.WAVMemoryStream.Position = 0; // Manually rewind stream soundPlayer.Stream = null; soundPlayer.Stream = sound.WAVMemoryStream; soundPlayer.PlaySync(); } }
public void fetchFromFeeds() { bool alertNew = false; for (int i = 0; i < rssDownloaderList.Count; i++) { RSSDownloader rssDownloader = rssDownloaderList[i]; List <SyndicationItem> syndicationItemList; if (lastPublishDate[i] == DEFAULT_DATE_TIME_OFFSET) { syndicationItemList = rssDownloader.TryGetAllItems(); } else { syndicationItemList = rssDownloader.TryGetItems(lastPublishDate[i]); } if (syndicationItemList == null) { //string url = rssDownloader.URL; string url = rssList[i]; System.Console.WriteLine("Download failed: \"" + url + "\""); continue; } // Update timestamp if (syndicationItemList.Count > 0) { foreach (SyndicationItem si in syndicationItemList) { if (ignoreKeywords || checkAgainstKeywordList(si.Title.Text)) { string dateTag = si.PublishDate.ToString("yyyy-MM-dd HH:mm:ss"); string itemText = dateTag + ": " + si.Title.Text; listBox.Items.Add(itemText); urlList.Add(si.Id); alertNew = true; } } lastPublishDate[i] = getLatestPublishDate(syndicationItemList); } } if (alertNew && _synthesizer != null) { List <string> wordList = new List <string>(2); List <double> silenceList = new List <double>(2); wordList.Add("new"); silenceList.Add(0.5); wordList.Add("alert"); silenceList.Add(0.5); WAVSound sentence = _synthesizer.GenerateWordSequence(wordList, silenceList); SoundPlayer soundPlayer = new SoundPlayer(); sentence.GenerateMemoryStream(); sentence.WAVMemoryStream.Position = 0; // Manually rewind stream soundPlayer.Stream = null; //TODO varför? soundPlayer.Stream = sentence.WAVMemoryStream; soundPlayer.Play(); } }