Speech to text
I am doing a project based on Natural Language Processing. I need to convert Speech to Text first and then check it for any grammatical errors in the text. I am stuck with the code for Speech to Text. I need an urgent help. Can anybody help me out with it?
My email id is pushkarjoshi2007@rediffmail.com- Moved byTaylorMichaelLMVP, ModeratorMonday, November 09, 2009 2:58 PMNot IDE related (From:Visual C# IDE)
Answers
- Hi,
You can use SpeechSynthesizer for this. To use this you should add System.Speech to your project as reference.
Here is a sample.
SpeechSynthesizer s = new SpeechSynthesizer();
s.SpeakAsync(txtSubject.Text);
Also here is a full code includes some more functionalities.using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Speech.Synthesis; namespace SystemSpeechMakale { public partial class frmSynthesizer : Form { SpeechSynthesizer s; public frmSynthesizer() { InitializeComponent(); s = new SpeechSynthesizer(); s.SpeakProgress += new EventHandler<SpeakProgressEventArgs>(s_SpeakProgress); s.StateChanged += new EventHandler<StateChangedEventArgs>(s_StateChanged); s.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(s_SpeakCompleted); } private void frmSynthesizer_Load(object sender, EventArgs e) { FillGenderCombo(); FillVoiceAgeCombo(); FillVoicesCombo(); } void s_SpeakProgress(object sender, SpeakProgressEventArgs e) { lblProgress.Text = e.Text; } private void btnSpeak_Click(object sender, EventArgs e) { if(rbtnGenderAge.Checked) { s.SelectVoiceByHints((System.Speech.Synthesis.VoiceGender)cmbGender.SelectedItem, (System.Speech.Synthesis.VoiceAge)cmbAge.SelectedItem); } else if (rbtnVoice.Checked) { s.SelectVoice(cmbVoice.SelectedItem.ToString()); } s.SpeakAsync(txtSubject.Text); } void s_SpeakCompleted(object sender, SpeakCompletedEventArgs e) { lblProgress.Text = ""; } void s_StateChanged(object sender, StateChangedEventArgs e) { lblState.Text = "Eski durum: " + e.PreviousState.ToString() + " Yeni durum: " + e.State; } private void FillGenderCombo() { cmbGender.DataSource = Enum.GetValues(typeof(VoiceGender)); } private void FillVoiceAgeCombo() { cmbAge.DataSource = Enum.GetValues(typeof(VoiceAge)); } private void FillVoicesCombo() { foreach (InstalledVoice iv in s.GetInstalledVoices()) { cmbVoice.Items.Add(iv.VoiceInfo.Name); } } private void cmbVoice_SelectedIndexChanged(object sender, EventArgs e) { IEnumerable<InstalledVoice> v = from a in s.GetInstalledVoices() where a.VoiceInfo.Name == cmbVoice.SelectedItem.ToString() select a; lblVoiceProperties.Text = "Cinsiyet: " + v.First<InstalledVoice>().VoiceInfo.Gender.ToString() + "\r\nYaş: " + v.First<InstalledVoice>().VoiceInfo.Age.ToString() + "\r\nAçıklama: " + v.First<InstalledVoice>().VoiceInfo.Description; } private void btnPause_Click(object sender, EventArgs e) { s.Pause(); } private void btnResume_Click(object sender, EventArgs e) { s.Resume(); } private void btnCancel_Click(object sender, EventArgs e) { Prompt p = s.GetCurrentlySpokenPrompt(); s.SpeakAsyncCancel(p); } private void btnWav_Click(object sender, EventArgs e) { s.SetOutputToWaveFile(@"C:\io.wav"); s.SpeakAsync(txtSubject.Text); } private void btnSSML_Click(object sender, EventArgs e) { s.SpeakSsmlAsync(txtSubject.Text); } } }
- Proposed As Answer byTamer OzMVPMonday, November 09, 2009 4:14 AM
- Marked As Answer byeryangMSFT, ModeratorThursday, November 12, 2009 7:52 AM
All Replies
- Hi,
You can use SpeechSynthesizer for this. To use this you should add System.Speech to your project as reference.
Here is a sample.
SpeechSynthesizer s = new SpeechSynthesizer();
s.SpeakAsync(txtSubject.Text);
Also here is a full code includes some more functionalities.using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Speech.Synthesis; namespace SystemSpeechMakale { public partial class frmSynthesizer : Form { SpeechSynthesizer s; public frmSynthesizer() { InitializeComponent(); s = new SpeechSynthesizer(); s.SpeakProgress += new EventHandler<SpeakProgressEventArgs>(s_SpeakProgress); s.StateChanged += new EventHandler<StateChangedEventArgs>(s_StateChanged); s.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(s_SpeakCompleted); } private void frmSynthesizer_Load(object sender, EventArgs e) { FillGenderCombo(); FillVoiceAgeCombo(); FillVoicesCombo(); } void s_SpeakProgress(object sender, SpeakProgressEventArgs e) { lblProgress.Text = e.Text; } private void btnSpeak_Click(object sender, EventArgs e) { if(rbtnGenderAge.Checked) { s.SelectVoiceByHints((System.Speech.Synthesis.VoiceGender)cmbGender.SelectedItem, (System.Speech.Synthesis.VoiceAge)cmbAge.SelectedItem); } else if (rbtnVoice.Checked) { s.SelectVoice(cmbVoice.SelectedItem.ToString()); } s.SpeakAsync(txtSubject.Text); } void s_SpeakCompleted(object sender, SpeakCompletedEventArgs e) { lblProgress.Text = ""; } void s_StateChanged(object sender, StateChangedEventArgs e) { lblState.Text = "Eski durum: " + e.PreviousState.ToString() + " Yeni durum: " + e.State; } private void FillGenderCombo() { cmbGender.DataSource = Enum.GetValues(typeof(VoiceGender)); } private void FillVoiceAgeCombo() { cmbAge.DataSource = Enum.GetValues(typeof(VoiceAge)); } private void FillVoicesCombo() { foreach (InstalledVoice iv in s.GetInstalledVoices()) { cmbVoice.Items.Add(iv.VoiceInfo.Name); } } private void cmbVoice_SelectedIndexChanged(object sender, EventArgs e) { IEnumerable<InstalledVoice> v = from a in s.GetInstalledVoices() where a.VoiceInfo.Name == cmbVoice.SelectedItem.ToString() select a; lblVoiceProperties.Text = "Cinsiyet: " + v.First<InstalledVoice>().VoiceInfo.Gender.ToString() + "\r\nYaş: " + v.First<InstalledVoice>().VoiceInfo.Age.ToString() + "\r\nAçıklama: " + v.First<InstalledVoice>().VoiceInfo.Description; } private void btnPause_Click(object sender, EventArgs e) { s.Pause(); } private void btnResume_Click(object sender, EventArgs e) { s.Resume(); } private void btnCancel_Click(object sender, EventArgs e) { Prompt p = s.GetCurrentlySpokenPrompt(); s.SpeakAsyncCancel(p); } private void btnWav_Click(object sender, EventArgs e) { s.SetOutputToWaveFile(@"C:\io.wav"); s.SpeakAsync(txtSubject.Text); } private void btnSSML_Click(object sender, EventArgs e) { s.SpeakSsmlAsync(txtSubject.Text); } } }
- Proposed As Answer byTamer OzMVPMonday, November 09, 2009 4:14 AM
- Marked As Answer byeryangMSFT, ModeratorThursday, November 12, 2009 7:52 AM


