Application of Chinese speech recognition technology in c # (2)

Source: Internet
Author: User

Next, the application of Chinese speech recognition technology in c # (I) ...... However, the method itself does not know the language of the string you are giving, so we need to read the string in what language. The Voice attribute of the SpVoiceClass class is used to set the language. We can use the GetVoices method of SpVoiceClass to obtain a list of all languages, and then select the corresponding language based on the parameter, for example, set the language to Chinese as follows:
Private void SetChinaVoice ()
{
Voice. Voice = voice. GetVoices (string. Empty, string. Empty). Item (0 );
}

0 indicates Chinese, 1234 indicates English, and the accent is different.
In this way, we set the language. If we combine the pronunciation method, we can design a method for sending only Chinese speech.
Private void SpeakChina (string strSpeak)
{
SetChinaVoice ();
Speak (strSpeak );
}

The method for sending only English speech is similar, as shown in the above program.
For a mix of Chinese and English languages, the method for the program to read the Mixed Speech is: programming separates the English and Chinese of the language, calls the SpeakChina Method for Chinese, and calls the speakengishi method in English; as for how to determine whether a character is English or Chinese, I use the asc code judgment method. The specific class method is implemented through AnalyseSpeak.
In this way, we only need to pass a piece of mixed Chinese and English text to AnalyseSpeak as a parameter, and he can complete the mixed Chinese and English pronunciation.
Of course, for the tentative, continue, stop and other operations of pronunciation, the above also provides a simple method call, it is easy to understand.
The following describes the methods for Chinese speech recognition:
First paste the source code of the Speech Recognition class below, and then explain:
Public class SpRecognition
{
Private static SpRecognition _ Instance = null;
Private SpeechLib. ISpeechRecoGrammar isrg;
Private SpeechLib. SpSharedRecoContextClass ssrContex = null;

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.