Universal Windows App Development with Cortana and the Speech SDK 4
2015-02-26 10:43
896 查看
4 Speech Recognition in Apps
4.1 Understanding In-App Speech Recognition
4.1.1 Speech Privacy Statement
User must accept the Privacy Statementcatch (Exception exception) { const uint HResultPrivacyStatementDeclined=0x80045509; if ((uint)exception.HResult == HResultPrivacyStatementDeclined) { var messageDialog=new Windows.UI.Popups.MessageDialog("You must accept the speech privacy policy to continue.", "Speecg Exception"); messageDialog.ShowAsync().GetResults(); this.recoEnabled=false; this.btnContinousRecognition.Content= "Start speech recognition"; } else { txtResult.Text=exception.Message; } }
4.1.2 Speech Recognition Constraints
Pre-defined grammarsCustom Grammars (can work offline)
PhraseList
4.1.3 In Application Basic Speech Recognition
//windows phone store app private async Task<SpeechRecognitionResult> RecognizeSpeech() { SpeechRecognizer recognizer=new SpeechRecognizer(); // one of three constraints types available SpeechRecognitionTopicConstraint topicConstraint =new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.WebSearch,"MSDN"); recongnizer.Constraints.Add(topicConstraint); await recognizer.ComplieConstarintAsync();// required //put up UI and recognize user's utterance SpeechRecognitionResult result= await recognizer.RecognizeWithUIAsync(); return result; } //calling code uses result.RecognitionResult.Text or result.RecognitionResult.SemanticInterpretation
create speech recognizer
create the constraint (type, constraint name)
add it to the recognizer
compile the constraint
private async void RecognizeWithDictationGrammar_Click(object sender, RoutedEventArgs e) { // Create an instance of SpeechRecognizer. var speechRecognizer = new Windows.Media.SpeechRecognition.SpeechRecognizer(); // Compile the dictation grammar that is loaded by default. await speechRecognizer.CompileConstraintsAsync(); this.heardYouSayTextBlock.Visibility = this.resultTextBlock.Visibility = Visibility.Collapsed; // Start recognition. try { Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeWithUIAsync(); // If successful, display the recognition result. if (speechRecognitionResult.Status == Windows.Media.SpeechRecognition.SpeechRecognitionResultStatus.Success) { this.heardYouSayTextBlock.Visibility = this.resultTextBlock.Visibility = Visibility.Visible; this.resultTextBlock.Text = speechRecognitionResult.Text; } } catch (Exception exception) { if ((uint)exception.HResult == App.HResultPrivacyStatementDeclined) { this.resultTextBlock.Visibility = Visibility.Visible; this.resultTextBlock.Text = "The privacy statement was declined."; } else { var messageDialog = new Windows.UI.Popups.MessageDialog(exception.Message, "Exception"); messageDialog.ShowAsync().GetResults(); } } } private async void Footer_Click(object sender, RoutedEventArgs e) { await Windows.System.Launcher.LaunchUriAsync(new Uri(((HyperlinkButton)sender).Tag.ToString())); } } }
4.2 Programmatic List Grammars
Also as phrase list grammarsDeal with recognition confidence
4.3 Custom SRGS Grammars
SRGS (Speech Recognition Grammar Specification)W3C stanrdar that allows you to create grammars for speech recognition scenarios ranging from basic to complex
- http://www.w3.org/TR/speech-grammar Ideal for advanced speech recognition scenarios
Allow for complex combos across several rules
4.4 Optimizing Speech Recognition
Using multiple grammarsTuning Timeouts
Managing Audio Input Issues : RecognitionQualityDegrade
4.5 Speech Recognition and Globalization
4.6 Speech Recognition Comparison Across Platforms
相关文章推荐
- Universal Windows App Development with Cortana and the Speech SDK 1 and 2 @Channel9
- Universal Windows App Development with Cortana and the Speech SDK 6
- Universal Windows App Development with Cortana and the Speech SDK 5
- Universal Windows App Development with Cortana and the Speech SDK 3
- Preparing and Submitting an Application to the App Store with xCode4.2 and iOS5 SDK
- WinFX Workflow:Simplify Development With The Declarative Model Of Windows Workflow Foundation. From Don Box & Dharma Shukla
- Windows Developer Power Tools: Turbocharge Windows Development with More Than 140 Free and Open Sour
- The study of Programming Windows with MFC--Ip Address control and Date control
- Windows cannot find the local profile and is logging you on with a temporary profile
- Mobile Development with C#:Building Native iOS, Android, and Windows Phone Applications
- Setting Up the Development Environment for SharePoint 2010 on Windows Vista, Windows 7, and Windows
- The Study of Programming Windows with MFC--Progress and Animate control
- 好文推荐:Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0
- Professional WPF Programming: .NET Development with the Windows Presentation Foundation
- Building Enterprise Applications with Windows Presentation Foundation and the
- Understanding the Flex 4 Spark Component Architecture and how to Build Custom Components with the Flex 4 SDK
- vs2005 build the wxwidgets for wince with windows mobile 6 sdk
- [转]Installing, Configuring and Using Windows Server AppFabric and the "Velocity" Memory Cache in 10 minutes
- Nullsoft Winamp Plug-in With Bitmapped UI, Docking and Restrictive Resizing - The Code Project - Dialog and Windows