Search code examples
javascriptwindows-10-universalcortanavcd

How can I get Cortana to use my new or updated Voice Command Definition files?


I use the following code to install my VCD file ("grammar") into Cortana:

Windows.ApplicationModel.Package.current.installedLocation.getFileAsync("VoiceCommandDefinitions.xml")
.then(Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.installCommandDefinitionsFromStorageFileAsync)
.then(() => Debug.writeln("Successfully installed VCD file");

Success is reported, but when I write a query into Cortana, the changes I've made to my VCD file aren't reflected in Cortana.

How can I force Cortana to actually use my updated grammar?


Solution

  • Cortana will only refresh its cache of grammars at the end of a voice interaction. Click on Cortana's microphone button, and then immediately dismiss the Cortana box. You should see your grammar changes reflected within seconds.

    Installed grammars are stored under %LOCALAPPDATA%\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\LocalState\Grammars\VoiceCommands.Components.0409.cfg. Live (i.e. cached) grammars are stored under %LOCALAPPDATA%\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\LocalState\Grammars\ReadOnlyGrammars\VoiceCommands.Components.0409.cfg. This copy is refreshed every time the user completes a voice interaction with Cortana.

    (No source, sorry. This information is based on an e-mail exchange I had with the Cortana devs at Microsoft.)