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;