2016-04-02 11 views
1

In der specification for vcd files heißt es, dass {*} verwendet wird, um alles anzupassen. Jedoch denn er Beispiel Befehl:Cortana Windows 10 UWP-Integration - Verwenden von {*} in VCD

<Command Name="addFoodLog"> 
     <Example> I had a burger for lunch </Example> 
     <!--Recording a drink--> 
     <ListenFor RequireAppName="BeforeOrAfterPhrase"> [I] drank [a] {*} with [my] {mealtime} </ListenFor> 
     <!--Recording a meal--> 
     <ListenFor RequireAppName="BeforeOrAfterPhrase"> [I] ate [a] {*} for [my] {mealtime} </ListenFor> 
     <ListenFor RequireAppName="BeforeOrAfterPhrase"> [I'm] having {*} for [my] {mealtime} </ListenFor> 
     <ListenFor RequireAppName="BeforeOrAfterPhrase"> [I] [just] had [a] {*} for {mealtime} </ListenFor> 
     <Feedback> Recording your {mealtime}</Feedback> 
     <Navigate /> 
</Command> 

das Ergebnis dieser Eingabe Drucken wird I drank a ... with my dinner

Gibt es sein, eine Möglichkeit zu bekommen, was eigentlich aus dem Text gesagt wurde? Oder ist das vielleicht ein Fehler?

Antwort

1

Wenn Sie ein Phrase-Thema verwenden, dann lösen Sie Ihr Problem, da es ein größeres Vokabular aufgreift.

Heres ein Beispiel:

<PhraseTopic Label="food"> 
    <Subject>Food</Subject> 
    <Subject>Drink</Subject> 
    <Subject>Meal</Subject> 
    <Subject>Food</Subject> 
</PhraseTopic> 

Kasse die Voice Command Definition elements and attributes für weitere Informationen

1

Im Folgenden finden Sie, wie Sie einen Suchbegriff erhalten, nicht aus einer Liste von Werten. Dies ist für HTML/JS, im Gegensatz zu XAML, aber sollte Ihnen eine gute Idee geben.

Die XML

<?xml version="1.0" encoding="utf-8" ?> 
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2"> 
    <CommandSet xml:lang="en-us" Name="FNOW_en-us"> 
     <AppName> YourAppName </AppName> 
     <Example> Search books </Example> 

     <Command Name="SearchFor"> 
      <Example> Search for Harry Potter </Example> 
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> find book {SearchTerm} </ListenFor> 
      <Feedback> Searching books </Feedback> 
      <Navigate /> 
     </Command> 

     <PhraseTopic Label="SearchTerm" Scenario="Search"/> 
    </CommandSet> 
</VoiceCommands> 

Die JavaScript

function handleVoiceCommand(args) { 
    var command, 
     commandResult, 
     commandName = '', 
     commandProperties = {}; 

    if (args.detail && args.detail.detail) { 
     command = args.detail.detail[0]; 

     if (command) { 
      commandResult = command.result; 

      if (commandResult) { 
       if (commandResult.rulePath) { 
        commandName = commandResult.rulePath[0]; 
       } 
       if (commandResult.semanticInterpretation) { 
        commandProperties = commandResult.semanticInterpretation.properties; 
       } 

       // Act on the different commands. 
       // Command Names are defined within VoiceCommands.xml. 
       switch(commandName) { 
        case 'SearchFor': 
         console.log('Cortana Command: SearchFor'); 
         console.log('Search Term: ' + commandProperties.SearchTerm[0]); 
         break; 
       } 
      } 
     } 
    } 
} 

WinJS.Application.addEventListener('activated', function (args) { 
    var appLaunchVoiceCommand; 

    appLaunchVoiceCommand = Windows.ApplicationModel.Activation.ActivationKind.voiceCommand || 16; 
    if (args.detail.kind === appLaunchVoiceCommand) { 
     return handleVoiceCommand(args); 
    } 
}); 

WinJS.Application.start();