The Chinese speech recognition technology in C # application (i) .... ..... However, the method itself does not know what language you are giving the string, so it is necessary to read the string in what language. The Voice attribute of the Spvoiceclass class is used to set the language, we can get all the list of languages through the Spvoiceclass Getvoices method, and then select the corresponding language according to the parameters, such as setting the language to Chinese as follows:
The only way to speak English speech is similar, the above program has.
For a combination of Chinese and English language, we let the program read the mixed speech method is: Programming the language of the Chinese and English separate, to call the Speakchina method, English call Speakenglishi method; As to how to judge whether a character is English or Chinese, I am using the method of judging the ASC code, the concrete class method is implemented through Analysespeak.
In this way, for a piece of Chinese and English mixed text, we simply pass it as a parameter to the Analysespeak, he can complete the mixed pronunciation in English and Chinese.
Of course, for the pronunciation of the tentative, continue, stop and other operations, the above also gives a simple method call, it is easy to understand.
The following is a brief introduction to Chinese speech recognition methods:
First put the class source code for the speech recognition below, and then explain:
public class Sprecognition
{
private static sprecognition _instance = null;
Private Speechlib.ispeechrecogrammar ISRG;
Private Speechlib.spsharedrecocontextclass Ssrcontex =null;
Private System.Windows.Forms.Control CDisplay;
Private Sprecognition ()
{
Ssrcontex = new Spsharedrecocontextclass ();
ISRG = Ssrcontex.creategrammar (1);
Speechlib._ispeechrecocontextevents_recognitioneventhandler Rechandle =
New _ispeechrecocontextevents_recognitioneventhandler (contexrecognition);
Ssrcontex.recognition + = Rechandle;
}
public void Beginrec (Control Tbresult)
We define the context and syntax of Ssrcontex and ISRG for speech recognition, and by setting the Isrg Dictationsetstate method, we can start or end the recognition, which is the Beginrec and Closerec method in the above program. CDisplay is where we use to output recognition results, and to be able to display results on most controls, I use a control class to define it. Of course, every speech recognition triggers the Ispeechrecocontextevents_recognitioneventhandler event, and we define a method contexrecognition to respond to the event, and output the recognition result in this method.
In this way, the Chinese speech processing some of the most basic problems have a simple solution, of course, this method has a lot of imperfect places, I hope that we put forward more criticism and common improvement.
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.