1. built-in Speech Recognition in Windows 7
2. Microsoft Lili-Chinese (China) is added for text-to-speech conversion, which supports both Chinese and English.
3. Female Voice and some phrases are correctly pronounced
The above gives me the impulse to make a small program; below:
1. Introduce SpeechLib. dll
2. Create a form
3. write code
Public partial class FormMain: Form
{
Public FormMain ()
{
InitializeComponent ();
}
Private void FormMain_Load (object sender, EventArgs e)
{
GetVoices ();
}
Private void GetVoices ()
{
SpVoice voice = new SpVoiceClass ();
ISpeechObjectTokens voices = voice. GetVoices ("","");
Var list = new List <string> ();
Foreach (ISpeechObjectToken token in voices)
List. Add (token. GetDescription (0 ));
CbSpeechType. DataSource = list;
}
Private void btnSpeechText_Click (object sender, EventArgs e)
{
SpeechText (null );
}
Private void SpeechText (string fileName)
{
Cursor = Cursors. WaitCursor;
SpFileStream stream = null;
SpVoice voice = new SpVoiceClass ();
If (fileName + ""! = "")
{
Stream = new SpFileStreamClass ();
Stream. Open (fileName, SpeechStreamFileMode. SSFMCreateForWrite, false );
Voice. AudioOutputStream = stream;
}
Voice. Voice = voice. GetVoices ("", ""). Item (cbSpeechType. SelectedIndex );
Voice. Volume = tbVol. Value;
Voice. Rate = tbSpeechSpeed. Value;
Voice. Speak (tbText. Text, SpeechVoiceSpeakFlags. SVSFDefault );
If (fileName + ""! = "" & Stream! = Null)
Stream. Close ();
Cursor = Cursors. Arrow;
}
Private void btnRecordSpeech_Click (object sender, EventArgs e)
{
Cursor = Cursors. WaitCursor;
Using (var saveFileDialog = new SaveFileDialog ())
{
SaveFileDialog. FileName = "MyVoice.wav ";
SaveFileDialog. Filter = "Wave (*. wav) | *. wav ";
If (saveFileDialog. ShowDialog () = DialogResult. OK)
{
SpeechText (saveFileDialog. FileName );
}
}
Cursor = Cursors. Arrow;
}
}
The preceding functions support reading texts in text boxes and output speech files in lecture texts;
Reference application scenarios:
1. Try it and then delete it.
2. Convert the novel text into audio for MP3 listening
3. Cheat children
Running environment requirements:
1. WINDOWS 7
2. Other unknown
It is better to put a piece of code, so this article is simple. Please download it and compile and run it.
/Files/Chinasf/AnySpeech.rar