Windows phone's own speech recognition

Source: Internet
Author: User

WindowsPhone Voice operations include the following:

1, the speech recognition inside the program, the user can enter through the speech recognition or complete the related task

2, the control program's voice command, the control program starts, opens, and can the page jump and so on operation

This article will build a simple speech recognition (the general will identify all the words, and use the SRGs syntax to identify the composition of a sentence)

SRGS (Speech recognition Grammar specification), you can define complex speech recognition rules. Such as: Identify with synonyms replaced the words, omitted to say the non-key words and so on.

SRGs must be saved to storgefile before being added to the properties of the SpeechRecognizer class.

//button click event to begin speech recognition
Private Async voidButton_Click (Objectsender, RoutedEventArgs e) {stringMessage ="";Try{SpeechRecognizer SpeechRecognizer=NewSpeechRecognizer ();
         
//The following two events will not be written speechrecognizer.statechanged+=speechrecognizer_statechanged; //Status change speechrecognizer.recognitionqualitydegrading+=speechrecognizer_recognitionqualitydegrading;//Voice quality //get the built-in SRGs grammar files, such as simply identifying the words that will be, don't do this three linesStorageFile file =awaitWindows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync ("Srgsgrammar.xml"); Speechrecognitiongrammarfileconstraint Grammarfile=Newspeechrecognitiongrammarfileconstraint (file); SPEECHRECOGNIZER.CONSTRAINTS.ADD (Grammarfile); //Add SRGs syntax constraint //SpeechRecognizer.UIOptions.ExampleText = "Here is an example of a UI time";    
//Analyze VoiceSpeechrecognitioncompilationresult Compilationresult =awaitSpeechrecognizer.compileconstraintsasync (); if(Compilationresult.status = =speechrecognitionresultstatus.success) {
varresult =awaitSpeechrecognizer.recognizeasync ();//No interface for speech recognition. Recognizewithuiasync (); is the displaythe identification interface of the system itselfif(result.) Confidence = =speechrecognitionconfidence.rejected)
{
Message="not recognized"; }Else{Resultmessage.text=result. Text;    //Recognition Results } }}Catch(Exception err) {message="Exception Information:"+ Err. Message +Err.  HResult; }
}

Srgsgrammar.xml file

<?xml version="1.0"encoding="Utf-8"? ><grammar version="1.0" Xml:lang="ZH-CN"Root="Mediamenu"Tag-format="semantics/1.0"xmlns=Http://www.w3.org/2001/06/grammar
Xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"><!-These are essential--<rule id=" City"Scope=" Public"> <one-of><!--match one of the phrases --<item> Beijing </item> <item> Shanghai </item> </one-of> </rule> <rule id=" Cross"Scope=" Public"> <one-of> <item> to </item> <item> to </item> <item> to </item> </one-of> </rule> <rule id="Menu"Scope=" Public"> <item> <ruleref uri="#date"/><!--The node that specifies additional rules for the association--<tag> out. Date = Reles.latest ();</tag> </item> <item repeat="0-1"> From </item><!--display 1 or 0 times --<item> <ruleref uri="#city"/> <tag> out. City = rulels.latest ();</tag> </item> <item> <ruleref uri="#cross"/> <tag> out. Cross = rulels.latest ();</tag> </item> <item> <ruleref uri="#city"/> <tag> out. City = rulels.latest ();</tag> </item> </rule></grammar>

The above can be realized "from (" from "optional") Beijing/Shanghai to/to/to Beijing/Shanghai "
Beijing to Shanghai, from Beijing to Shanghai, Beijing to Shanghai, from Shanghai to Beijing, Shanghai to Beijing and so on.

Unfortunately, the place of departure and arrival can be repeated. And only supports specific rules such as "(from) the place of departure---arrival"

If you say more of the other words, you will recognize the error.

PS: The recent project to add speech recognition features, requires the use of Baidu speech recognition Sdk/api, but the former only support Android and iphone

The latter is common to all platforms, but the workload is a little bit bigger, it has to be recorded first, then transmitted through HttpWebRequest and API data, parsing.

Windows phone's own speech recognition

Related Article

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.