A Tutorial Introduction to SALT7. The <LISTEN> elementA SALT <listen> element creates an object that can recognise speech spoken by the user. We can script control of the object to specify the recognition grammar and when it should start. The object returns a recognition structure which can contain detailed acoustic scores and semantic mark-up as well as a word string. The semantic mark-up is discussed later in the tutorial. Here we give a basic introduction to the <listen> element below, but for a more complete description refer to the SALT specification or the SASDK documentation. 7.1 XML structureThe essential XML structure of a <prompt> object is as follows: <listen> <grammar attributes /> // Describes the recognition grammar <bind attributes /> // Passes recognised text to another object <record attributes /> // Configures recording of audio <param attributes /> // Speech system configuration <audiometer attributes /> // Configures level meter display </listen> The <audiometer> element is specific to the Microsoft Speech add-in for Internet Explorer. 7.2 AttributesThe attributes of the <listen> element are as follows:
7.3 PropertiesA listen object has the following interesting properties:
7.4 MethodsA listen object has the following methods that may be called from a script function.
7.5 The listen <grammar> elementThe <grammar> sub-element can be used to enclose a grammar specification in W3C Speech Recognition Grammar Specification (SRGS) format. It also has the following attributes:
The speech recognition grammar format is described in the next section. To store grammars in an external file, use SALT mark-up like this: <salt:grammar src="colours.grxml" /> Then the file "colours.grxml" might contain: <grammar version="1.0" xml:lang="en-US" xmlns="http://www.w3.org/2001/06/grammar" root="colours"> <rule id="colours" scope="public"> <one-of> <item>black</item> <item>blue</item> <item>gray</item> <item>green</item> <item>purple</item> <item>red</item> <item>silver</item> <item>white</item> <item>yellow</item> </one-of> </rule> </grammar> 7.6 The listen <bind> elementThe <bind> sub-element can be used to send recognition results to some other object in the web page. It has the following attributes:
7.7 The listen <record> elementThe <record> sub-element specifies that an audio recording is to be made. If a grammar element contains a <record> element and a grammar, then the record element takes precedence and a recording rather than a recognition is performed. The record element has the following attributes:
Example audio recording applicationThe following application records an audio message and replays it. Try out on your computer: Normal version, Debug version.
<html xmlns:salt="http://www.saltforum.org/2002/SALT">
<object id="speech-add-in" CLASSID="clsid:33cbfc53-a7de-491a-90f3-0e782a7e347a">
</object>
<?import namespace="salt" implementation="#speech-add-in"/>
<!-- SALT: Record audio -->
<salt:listen id="recAudio" onreco="doSaveAudio()" onnoreco="doSaveAudio()">
<salt:record beep="true" type="audio/x-wav" />
</salt:listen>
<!-- SALT: Playback audio -->
<salt:prompt id="playAudio">
<salt:content id="contentAudio" href="" type="audio/x-wav">
</salt:prompt>
<body>
<h1>SALT: Record and Echo Audio</h1>
<p><input name="txtFilename" type="text" size=80 onclick="recAudio.Start()" />
<p>Click in text field, wait for level meter, speak message.
</body>
<script>
function doSaveAudio()
{
// set text field to name of temporary file
var pField=document.getElementById("txtFilename");
var pAudio=document.getElementById("recAudio");
pField.value=pAudio.recordlocation;
// set replay audio source to filename
var pContent=document.getElementById("contentAudio");
pContent.href=pAudio.recordlocation;
// start replay
var pPlay=document.getElementById("playAudio");
pPlay.Start();
}
</script>
</html>
Next: speech recognition grammars.
|
|
University College London - Gower Street - London - WC1E 6BT - |