You can improve the performance of voice applications by using a combination of fetching and caching to prime the cache with referenced audio, script and grammar files before your application starts. To do this, create a VoiceXML application root document that contains a form that will never be visited. In this form, specify the audio, script and grammar tags that will be referenced by the application. the form should reference the appropriate fetching properties described by the VoiceXML specification, for example <property name=“grammarfetchhint” value=“prefetch”/>. It is important to note that the default behavior is to prefetch all resources except for documents. If certain resources can not be cached or expire immediately, applications should disable caching for these resources (using property or attribute names) to improve system performance.
Here is a two-document application illustrating the preloading of grammar for customer inquiries on laptop computers:
Application root document (preload.vxml)
<?xml version="1.0" encoding="iso-8859-1"?> <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml" xml:lang="en-US"> <form id="loadgrammar"> <grammar src="laptops.grxml" type="application/srgs+xml" fetchhint="prefetch" scope="document"/> </form> </vxml>
Main document (main.vxml)
<?xml version="1.0" encoding="iso-8859-1"?> <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml" xml:lang="en-US" application="preload.vxml"> <form id="greeting"> <block> <prompt> Welcome to Laptops at Your Fingertips. At any time, you can say help or stop. <break time="large"/> </prompt> <goto next="getModel.vxml"/> </block> </form> </vxml>
When the first document (main.vxml) in the Voice application is loaded, the application root document (preload.vxml) is also loaded. The VoiceXML browser loads the referenced grammar file (laptops.grxml) and stores them in the cache.
You can use the dtjcache command to display or expire contents of the Blueworx Voice Response VoiceXML cache. You can select one or all documents or voice prompt files in the cache to expire. New versions of any expired contents will be fetched when an application next requests their use from the cache. Content in the process of being loaded cannot be expired until fully loaded. See dtjcache script for details.
By default, Blueworx Voice Response creates only one VoiceXML 2.x cache directory for use by all application nodes in a Java and VoiceXML environment. However, it is possible for each node to use its own directory, which can lead to performance improvements.
To configure each node to use its own cache directory, complete the following steps:
dtjstop dtjshost -exit
JavaCommand=javaexe -Dwvr.vxml2.cachedir=directory(where javaexe is name of the Java executable (for example: /usr/java14/jre/bin/java), and directory is the absolute path of the cache directory you want to use.
-Dwvr.vxml2.cachedir=directoryto the end of the JavaCommand line.
dtjshost dtjstartThe new cache directory is created automatically if it does not already exist.
To increase the size of the grammar cache:
wvr.vxml2.grammar.memcachesize=20000