Developing Web applications that manage lexicons

Last reviewed: 7/15/2011

HOW Article ID: H071120

The information in this article applies to:

  • LexiconKit 4

Summary

You can develop web applications that manage lexicons using your favorite JavaScript and VBScript development tools.

More Information

LexiconKit class methods require enumeration constant values for some of the parameters. These constants are pre-defined in files chant.js and chant.vb. Copy the applicable file to the same folder as your web page from the following installation folder:

Program Files\Chant\LexiconKit 4\Win32\Web\include.

Program Files\Chant\LexiconKit 4\Win64\Web\include.

Program Files\Chant\LexiconKit 4\WinCE\Web\include.


Access the constant values on your web page by including a reference to the file on your web page.


<head>
<script type="text/javascript" language="JavaScript" src="chant.js" />
... 
</head>
<body onload="onLoad()">
...
</body>

<head>
    <script type="text/vbscript" language="vbscript" src="chant.vb" />
    ...
</head>
<body onload="onLoad()">
...
</body>

Object Declaration

Chant LexiconKit includes a Web component library that can be accessed via script code on a web page.

The ChantLM component can be accessed via JavaScript and VBScript code on a web page. The IE browser caches the component automatically for the web page.


<!-- IE 32 declaration -->
<object id="WChantLM1" width="0" length="0"
classid="clsid:8C4C4759-B16B-44D0-BD75-069E17A4E07D"
codebase="http://www.chant.net/lexiconkit/cabs/WLexiconKit4.cab">
</object>
        

The ChantLM component can be accessed via JavaScript and VBScript code on a web page. The IE browser caches the component automatically for the web page. The 64-bit library declaration is only required when using 64-bit IE.


<!-- IE 64 declaration -->
<object id="WChantLM1" width="0" length="0"
classid="clsid:64420A19-AA75-4D23-ACCB-21211C73F1D1"
codebase="http://www.chant.net/lexiconkit/cabs/WLexiconKit4.cab">
</object>

The ChantLM component can be accessed via JavaScript code on a web page. Pocket IE browser does not support VBScript and does not cache the component automatically for the web page. The web component library must be installed on the device first.


<!-- Pocket IE declaration -->
<object id="WChantLM1" width="0" length="0"
classid="clsid:4604DB57-73F4-4374-A6BA-65C48B32CF13">
</object>

To install the web component library on the device, run the Program Files\Chant\LexiconKit 4\WinCE\lxkwebsetup.exe or copy the Program Files\Chant\LexiconKit 4\WinCE\WSpeechKitWCEARM4.cab to the device and execute to install.


Object Instantiation

The ChantLM class object is automatically instantiated when the web page loads. Access the instance of the ChantLM object from the document object. Set the CSPSerials property with your LexiconKit license serial number to unlock the component library for this web page. Even though you access the ChantLM object instance from as many functions as your application needs, you only need to set the CSPLicense once on page load.


<head>
<script type="text/javascript" language="JavaScript"><!--
    function onLoad() {
        // Get the object instance (Win32 and Win64)
        var chantLM = document.getElementById('WChantLM1');
        // Get the object instance (WinCE)
        var chantLM = document.all['WChantLM1'];

        // Set license property
        chantLM.SetStringProperty(CSPSerials,"LicenseSerialNumber");

        ...
    }
//-->
</script>
</head>
<body onload="onLoad()">
...
</body>

<head>
    <script type="text/vbscript" language="vbscript"> <!--
    Sub onLoad
        ' Get the object instance (Win32 and Win64. VBScript not supported on WinCE)
        Set chantLM = document.getElementById("WChantLM1")

        ' Set  license property
        chantLM.SetStringProperty CSPSerials, "LicenseSerialNumber" 
    End Sub
//-->
</script>
</head>
<body onload="onLoad()">
...
</body>

Event Callbacks

Event callbacks are the mechanism in which the component library sends information back to the application such as phoneme selection, import/export processing state, or there was an error.


<script type="text/javascript" language="JavaScript" for="WChantLM1" event="HasEvent"><!--
    var wChantLMEvent;

    var chantLM = document.getElementById('WChantLM1');
    // Get the number of events
    numberOfEvents = chantLM.GetResourceCount(CSREvent);
    for (i = 0; i < numberOfEvents; i++)
    {
        // Get the event from the event queue
        wChantLMEvent = chantLM.GetResource(CSREvent, 0);
        switch (wChantLMEvent.ChantCallback)
        {
            case ChantCallback.CCTTSPhoneme:
                {
                    ...       
                }
            default:
                break;
        }
        // Remove the event from the event queue
        chantLM.RemoveResource(CSREvent, 0, 0, "");
    }
//-->
</script>

<script  type="text/vbscript" language="vbscript" for="WChantLM1" event="HasEvent"><!--
    Set chantLM = document.getElementById("WChantLM1")
    ' Get the number of events
    numberOfEvents = chantLM.GetResourceCount(CSREvent)
    For I = 0 To numberOfEvents-1
        ' Get the event from the event queue
        Set wChantLMEvent = chantLM.GetResource(CSREvent, 0)

        ' Process the type of callback event
        Select Case wChantLMEvent.ChantCallback
            Case ChantCallback.CCTTSPhoneme
                 ...
            Case Else
        End Select

        ' Remove the event from the event queue
        chantLM.RemoveResource CSREvent, 0
    Next
//-->
</script>

Deployment Checklist

When you are ready to deploy your application, you need to ensure you have a valid license, bundle the correct Chant component libraries, and configure your installation properly on the target system. Review the following checklist before deploying your applications:

  • You may deploy your web page to any domain with a valid license from the Chant.
  • Update the codebase tag in the <object> declaration with location of the LexiconKit cab file. This can be the Chant web location or the URL of that location on your website where you copy the licensed cab file.

Sample Projects

Web sample projects are installed at the following location:

  • My Documents\Chant LexiconKit 4\Win32\Web\JavaScript.
  • My Documents\Chant LexiconKit 4\Win64\Web\JavaScript.
  • My Documents\Chant LexiconKit 4\WinCE\Web\JavaScript.