Call Windows 7 to read both Chinese and English

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.