30
Thanks all for voting #StopDengue

MS Champs meetup may 2014 on Cortana

Embed Size (px)

Citation preview

Page 1: MS Champs meetup may 2014 on Cortana

Thanks all for voting

#StopDengue

Page 2: MS Champs meetup may 2014 on Cortana
Page 3: MS Champs meetup may 2014 on Cortana

We all know about Cortana

She does•Call Hubby, mobile

•Text Hubby hi sweety

•Change my 3 pm appointment to 4

•Next time I’m at the Microsoft, remind me to

meet Wela

•Take note: left my car on level 4

•Wake up me in 20 minutes

•Play Hariharan

•Find cheap pizza restaurant near me

•Do I need an umbrella

Page 4: MS Champs meetup may 2014 on Cortana

“Take note: left my car on level 4”

Where does the note go?

Page 5: MS Champs meetup may 2014 on Cortana

Boooorrrrring !!

Old stories

ENOUGH!

Page 6: MS Champs meetup may 2014 on Cortana

OK...!Lets

HACK

Page 7: MS Champs meetup may 2014 on Cortana

The <big>IDEA</big>

Everyone knows

Only hackers know

Page 8: MS Champs meetup may 2014 on Cortana

Confusing?

Page 9: MS Champs meetup may 2014 on Cortana

EXAMPLE scenario

Me : Set colour to RedCortana : Setting colour to Red[Win 8 & WP apps shows Red colour background]

Me : Set colour to BlueCortana : Settings colour to Blue[Win 8 & WP apps shows Red colour background]

Page 10: MS Champs meetup may 2014 on Cortana

REAL LIFE scenarioMe : Switch on bulb 1Cortana : Switching bulb 1 on[One bulb in the room gets light]

Me : Switch off bulb 1Cortana : Switching bulb 1 off[One bulb in the room gets off from light]

Me : Switch off bulb 1Cortana : YAKO!! Its already off

Page 11: MS Champs meetup may 2014 on Cortana

Real life IDEA

Page 12: MS Champs meetup may 2014 on Cortana

Fly balloons with CORTANA

Page 13: MS Champs meetup may 2014 on Cortana

Lets

/build//

Page 14: MS Champs meetup may 2014 on Cortana

/build//

Voice Command

Page 15: MS Champs meetup may 2014 on Cortana

Easy

3 steps

Page 16: MS Champs meetup may 2014 on Cortana

Create Voice Command Definition(s)

Register VCD XML on App Startup

Handle Voice Command Activation

Page 17: MS Champs meetup may 2014 on Cortana

Refer:http://channel9.msdn.com/Events/Build/2014/2-530

Page 18: MS Champs meetup may 2014 on Cortana

<?xml version="1.0" encoding="utf-8"?><VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">

  <CommandSet xml:lang="en-us" Name="englishCommands">     <CommandPrefix>MSDN</CommandPrefix>    <Example>How do I add Voice Commands to my application</Example>     <Command Name="FindText">      <Example>Find Install Voice Command Sets</Example>      <ListenFor>Search</ListenFor>      <ListenFor>Search for {dictatedSearchTerms}</ListenFor>      <ListenFor>Find</ListenFor>      <ListenFor>Find {dictatedSearchTerms}</ListenFor>      <Feedback>Search on MSDN</Feedback>      <Navigate Target="MainPage.xaml" />    </Command>     <Command Name="nlpCommand">      <Example>How do I add Voice Commands to my application</Example>      <ListenFor>{dictatedVoiceCommandText}</ListenFor>      <Feedback>Starting MSDN...</Feedback>      <Navigate Target="MainPage.xaml" />                           </Command>     <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">      <Subject>MSDN</Subject>    </PhraseTopic>     <PhraseTopic Label="dictatedSearchTerms" Scenario="Search">      <Subject>MSDN</Subject>    </PhraseTopic>   </CommandSet> </VoiceCommands>

Page 19: MS Champs meetup may 2014 on Cortana

private async void RegisterVoiceCommands(){ // SHOULD BE PERFORMED UNDER TRY/CATCH Uri uriVoiceCommands = new Uri("ms-appx:///vcd.xml", UriKind.Absolute)); await VoiceCommandService.InstallCommandSetsFromFileAsync(uriVoiceCommands);

// Please note that VoiceCommandService ends with WP8.1 (End of Silverlight era) // (ie) No more .xap’s after WP8.1. Only .appx’s}

Windows Phone Silverlight Apps on Windows Phone 8.1

Windows Runtime Apps on Windows Phone 8.1

private async void RegisterVoiceCommands(){ // SHOULD BE PERFORMED UNDER TRY/CATCH Uri uriVoiceCommands = new Uri("ms-appx:///vcd.xml", UriKind.Absolute); StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uriVoiceCommands); await VoiceCommandManager.InstallCommandSetsFromStorageFileAsync(file); // No need to define Capabilities in app manifest}

Page 20: MS Champs meetup may 2014 on Cortana

VCD Commands and Targets

YourPage.xamlSYSTEM

Silverlight App

System launches app on page specified by Target

Page code maps commands (intents) into actions

Page 21: MS Champs meetup may 2014 on Cortana

// Windows Phone Silverlight App, in MainPage.xaml.cs

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e){ base.OnNavigatedTo(e);

if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New) { string recoText = null; // What did the user say? e.g. MSDN, "Find Windows Phone Voice Commands" NavigationContext.QueryString.TryGetValue("reco", out recoText);

string voiceCommandName = null; // Which command was recognized in the VCD.XML file? e.g. "FindText" NavigationContext.QueryString.TryGetValue("voiceCommandName", out voiceCommandName);

string searchTerms = null; // What did the user say, for named phrase topic or list "slots"? e.g. "Windows Phone Voice Commands" NavigationContext.QueryString.TryGetValue("dictatedSearchTerms", out searchTerms);

switch (voiceCommandName) // What command launched the app? { case "FindText": HandleFindText(searchTerms); break;

case "nlpCommand": HandleNlpCommand(recoText); break; } }}

Page 22: MS Champs meetup may 2014 on Cortana

VCD Commands and Targets

SYSTEMApp class

YourPage.xaml

Windows Runtime App

System tells code in App class what command and target were used

Code in App class navigates to page

Page code maps commands (intents) into actions

Page 23: MS Champs meetup may 2014 on Cortana

// Windows Runtime App on Windows Phone 8.1, inside OnActivated override in App class

if (args.Kind == ActivationKind.VoiceCommand){ VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args;

  string voiceCommandName = vcArgs.Result.RulePath.First(); // What command launched the app?

switch (voiceCommandName) // Navigate to right page for the voice command { case "FindText": // User said "find" or "search" rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result); break;

case "nlpCommand": // User said something else rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result); break; }}

Page 24: MS Champs meetup may 2014 on Cortana

/build//

Bluetoothpairing

Page 25: MS Champs meetup may 2014 on Cortana

Refer :http://blogs.msdn.com/b/flecoqui/archive/2013/12/13/windows-store-and-windows-phone-app-to-app-communication-over-bluetooth.aspx

Page 26: MS Champs meetup may 2014 on Cortana

“Cortana, recharge mom’s

mobile with 50 rupees”

Page 27: MS Champs meetup may 2014 on Cortana

Good exampleDialog eWallet

Page 28: MS Champs meetup may 2014 on Cortana

eZ charging API - Charge the cost of digital goods

eZ Cash API - transfer funds between two eZ Cash wallets and check

the transaction history.

Page 29: MS Champs meetup may 2014 on Cortana

http://1drv.ms/RucQqc

Page 30: MS Champs meetup may 2014 on Cortana

http://1drv.ms/RucQqc