However, this method itself does not know what language you give, so what is the language to read it this string. The Voice property of the SPVoiceClass class is used to set the language, we can get all the list of languages through the SpvoiceClass method, and then select the corresponding language according to the parameters, such as setting the language as the following:
Private void setChinavoice ()
{
Voice.Voice = Voice.GetVoices (String.empty, String.empty) .Item (0);
}
0 indicates that Han, 1234 represent English, the accent.
In this way, we set a language, if combined with a pronunciation method, we can design a method of only Chinese speech.
Private vid SpeakChina (String Strspeak)
{
SetChinaVoice ();
SPEAK (STRSPEAK);
}
Methods of only English speech are also similar, and there are in the above program.
For a language mixed language, we let the program read the method of mixing the mixed speech is: Programming the Chinese and English of this language, calling the speakenglishi method in Chinese, English calls SpeakengLishi method; As for how to determine a character is English or Chinese, I use the method of judging the ASC code, and the specific class method is achieved by Analysis Upak.
In this way, for a parameter, we can complete the mixed pronunciation of Chinese and English as parameters.
Of course, for pronunciation, continuing, stop, etc., it also gives a simple method call, which is easy to understand.
The following is a brief introduction to the method of Chinese speech recognition:
Put the source code of the voice recognition first, then do it again:
Public Class Sprecognition
{
Private static sprecognition _INSTANCE = NULL;
Private Speechlib.ispeechrecogrammar ISRG;
Private Speechlib.spsharedRecocontextClass Srcontex = NULL;
Private system.windows.Forms.Control cdisplay;
Private spractalnition ()
{
SSRCONTEX = New SPSharedRecocontextClass ();
ISRG = SSRCONTEX.CREATEGRAMMAR (1);
Speechlib._ispeechrecocontextevents_recognitionEventHandler Rechandle =
New _ispeechrecocontextevents_recognitionEventhandler (ContexRecognition);
SSRCONTEX.RECognition = recn;
}
Public void beginRec (Control TBRESULT)
{
Isrg.dictationSetState (SpeechRulestate.sgdsactive);
Cdisplay = TBRESULT;
}
Public static sprecognition installation ()
{
IF (_Instance == null)
_INSTANCE = new sprecognition ();
Return_INSTANCE;
}
Public void closec ()
{
ISRG.DictationSetState (SpeechRulestate.sgdsinActive);
}
Private Void ContexRecognition (int Iindex, Object Obj, Speechlib.SpeechRecognitionType Type, Speechlib.ispeechRecoresult Result)
{
cdisplay.text = Result.phraseInfo.getText (0, -1, true);
}
}
We define the context and syntax for SSRCONTEX and ISRG for speech recognition. By setting ISRG's DictationState method, we can start or end identification, which is BeginRec and Closerec methods in the above program. Cdisplay is where we use to output identification results, in order to display results on most controls, I use a Control class to define it. Of course, the ISPEECOCONTEXTEVENTS_RECognitionEventHndler event is triggered after each speech recognition, and we define a method ContexRecognition to respond to events and output identification results in this method.
In this way, some of the most basic issues of Chinese speech processing have a simple solution. Of course, this approach has a lot of imperfect places. I hope that everyone will propose more criticism and improve.