private void insertEndPointSilenceButton_Click(object sender, EventArgs e) { int selectedIndex = formantSpecificationListBox.SelectedIndex; FormantSettings initialSilenceSettings = new FormantSettings(); double duration = double.Parse(endPointSilenceDurationTextBox.Text); initialSilenceSettings.SetSilence(duration); editorFormantSpecification.FormantSettingsList.Insert(0, initialSilenceSettings); FormantSettings finalSilenceSettings = new FormantSettings(); finalSilenceSettings.SetSilence(duration); // Generate the transition to the final silence period: FormantSettings lastFormantSettings = editorFormantSpecification.FormantSettingsList.Last(); double lastFormantSettingsDuration = lastFormantSettings.Duration; if (lastFormantSettingsDuration < duration) { lastFormantSettings.TransitionStart = 0; } else { double startFraction = 1 - (duration / lastFormantSettingsDuration); lastFormantSettings.TransitionStart = startFraction; } // Then add the final silence: editorFormantSpecification.FormantSettingsList.Add(finalSilenceSettings); ShowFormantSpecification(selectedIndex + 1); }
private void GenerateNewSpeechSynthesizer() { speechSynthesizer = new FormantSpeechSynthesizer(); speechSynthesizer.StorePitch = true; FormantSpecification longSilenceSpecification = new FormantSpecification(speechSynthesizer.FundamentalFrequency, speechSynthesizer.SamplingFrequency); longSilenceSpecification.Name = "="; FormantSettings longSilenceSettings = new FormantSettings(); longSilenceSettings.SetSilence(LONG_SILENCE_SOUND_DURATION); longSilenceSpecification.FormantSettingsList.Add(longSilenceSettings); speechSynthesizer.SpecificationList.Add(longSilenceSpecification); FormantSpecification shortSilenceSpecification = new FormantSpecification(speechSynthesizer.FundamentalFrequency, speechSynthesizer.SamplingFrequency); shortSilenceSpecification.Name = "-"; FormantSettings shortSilenceSettings = new FormantSettings(); shortSilenceSettings.SetSilence(SHORT_SILENCE_SOUND_DURATION); shortSilenceSpecification.FormantSettingsList.Add(shortSilenceSettings); speechSynthesizer.SpecificationList.Add(shortSilenceSpecification); }