locked
VoiceCommandService.InstalledCommandSets is always empty RRS feed

  • Question

  • I am trying to update the phrase list at runtime but even though my voice command xml is installed (it works for hardcoded phrase lists) whenever I access VoiceCommandService.InstalledCommandSets it is always empty.
    Thursday, November 1, 2012 6:24 PM

Answers

  • This same problem occurred during my tests in the preview SDK too; Mark's suggestion to me was to do this in the XML definition:

    <CommandSet xml:lang="en-US" Name="Name12">

    and reference it like this:

    VoiceCommandSet widgetVcs = VoiceCommandService.InstalledCommandSets["Name12"];

    I think once the XML sees a Name attribute in the XML, the InstalledCommandSets array gets filled in.



    • Edited by Darin Rousseau Friday, November 2, 2012 7:26 PM Site error during post
    • Marked as answer by erothvt Friday, November 2, 2012 9:01 PM
    Friday, November 2, 2012 7:26 PM

All replies

  • Could you post your code?

    Also, did you wrap you call to VoiceCommandService.InstallCommandSetsFromFileAsync in a try/catch? If not, "try" that, and make sure that it's not throwing an exception.


    Rob Chambers [MSFT]

    http://blogs.msdn.com/b/robch/

    ------------------------------

    This posting is provided "AS IS" with no warranties, and confers no rights.


    Thursday, November 1, 2012 8:12 PM
  • try
                {
                    await VoiceCommandService.InstallCommandSetsFromFileAsync(
                        new Uri("ms-appx:///SpotExplorer.xml"));
                }
                catch (Exception e )
                {
                    
                }
                if (VoiceCommandService.InstalledCommandSets.Any())
                {
                    var widgetVcs = VoiceCommandService.InstalledCommandSets["en-US"];
                    await widgetVcs.UpdatePhraseListAsync("route", ViewModel.Routes.Select(r => r.Name).ToArray());
                }

    I put in the any check because it was throwing key not found exception.

    Here is the xml:

    <?xml version="1.0" encoding="utf-8"?>
    <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.0">
      <CommandSet xml:lang="en-us">
        <Example> Open Route </Example>
        <Command Name="openRoute">
          <Example> Open Seattle </Example>
          <ListenFor> [open] {route} </ListenFor>
          <Feedback> Opening {route} </Feedback>
          <Navigate Target="/RoutesPage.xaml"/>
        </Command>
    
        <PhraseList Label="route">
          <Item>Seattle</Item>
        </PhraseList>
    
      </CommandSet>
    
      <!-- Other CommandSets for other languages -->
    
    </VoiceCommands>

    Thursday, November 1, 2012 8:49 PM
  • This same problem occurred during my tests in the preview SDK too; Mark's suggestion to me was to do this in the XML definition:

    <CommandSet xml:lang="en-US" Name="Name12">

    and reference it like this:

    VoiceCommandSet widgetVcs = VoiceCommandService.InstalledCommandSets["Name12"];

    I think once the XML sees a Name attribute in the XML, the InstalledCommandSets array gets filled in.



    • Edited by Darin Rousseau Friday, November 2, 2012 7:26 PM Site error during post
    • Marked as answer by erothvt Friday, November 2, 2012 9:01 PM
    Friday, November 2, 2012 7:26 PM