⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch18.htm

📁 MAPI__SAPI__TAPI
💻 HTM
📖 第 1 页 / 共 5 页
字号:
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;// Michelles, Michelles Supplies<br>
  &nbsp;&nbsp;&nbsp;&nbsp;seq( Michelles opt( Supplies )opt )seq <br>
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;// The Sports Barn, Sports Barn<br>
  &nbsp;&nbsp;&nbsp;&nbsp;seq( opt( The )opt Sports Barn )seq<br>
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;// Security, Security Office<br>
  &nbsp;&nbsp;&nbsp;&nbsp;seq( Security opt( Office )opt )seq<br>
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;// Main Office<br>
  &nbsp;&nbsp;&nbsp;&nbsp;seq( Main Office )seq<br>
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;// Food, Food Court, Food Shops<br>
  &nbsp;&nbsp;&nbsp;&nbsp;seq( Food opt( alt( Court Shops )alt )opt )seq<br>
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;// Specialty Shops<br>
  &nbsp;&nbsp;&nbsp;&nbsp;seq( Specialty Shops )seq<br>
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;// Exits<br>
  &nbsp;&nbsp;&nbsp;&nbsp;Exits<br>
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;// Restroom<br>
  &nbsp;&nbsp;&nbsp;&nbsp;Restroom<br>
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;// Fountain<br>
  &nbsp;&nbsp;&nbsp;&nbsp;Fountain<br>
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;)alt ;</font></tt> </p>
</blockquote>

<hr>

<p>The last step is to build a set of query rules. These are rules that contain the 
questions customers will commonly ask of the workstation. Each of these questions is 
really a short phrase followed by a store or location name. Listing 18.19 shows how you 
can implement the query rules defined in the <tt><font FACE="Courier">&lt;Start&gt;</font></tt> 
rule. </p>

<hr>

<blockquote>
  <b><p>Listing 18.19. Adding the query rules to the <tt><font FACE="Courier">MALL.TXT</font></tt> 
  grammar file.<br>
  </b></p>
</blockquote>

<blockquote>
  <tt><font FACE="Courier"><p>//&nbsp;************************************* <br>
  //&nbsp;Define simple queries<br>
  //<br>
  //&nbsp;These rules respond to customer<br>
  //&nbsp;queries<br>
  //<br>
  &lt;_TellMeWhere&gt; = seq( Tell me where &lt;_Locations&gt; is )seq ;<br>
  &lt;_HowCanIFind&gt; = seq( How can I find opt( the )opt &lt;_Locations&gt; )seq ;<br>
  &lt;_ShowMe&gt; = seq( Show me opt( where )opt &lt;_Locations&gt; opt( is )opt )seq ;<br>
  &lt;_WhereIs&gt; = seq( Where is &lt;_Locations&gt; )seq ;<br>
  <br>
  //<br>
  //&nbsp;eof</font></tt> </p>
</blockquote>

<blockquote>
  <tt><font FACE="Courier"><p>//</font></tt> </p>
</blockquote>

<hr>

<p>Notice the use of the <tt><font FACE="Courier">opt()</font></tt> functions to widen the 
scope of the rules. These add flexibility to the grammar without adding extra rules. </p>
<div align="center"><center>

<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
  <tr>
    <td><b>Note</b></td>
  </tr>
  <tr>
    <td><blockquote>
      <p>Be sure to save the file as <tt><font FACE="Courier">MALL.TXT</font></tt> before you 
      continue on to the next step. </p>
    </blockquote>
    </td>
  </tr>
</table>
</center></div>

<h4>Compiling the <tt><font FACE="Courier">MALL.TXT</font></tt> Grammar File</h4>

<p>After you have constructed the grammar file, you are ready to compile it into a binary 
form understood by the SAPI SR engine. </p>
<div align="center"><center>

<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
  <tr>
    <td><b>Note</b></td>
  </tr>
  <tr>
    <td><blockquote>
      <p>To do this, you need to use the <tt><font FACE="Courier">GRAMCOMP.EXE</font></tt> 
      program that ships with the Speech SDK. You can find this program in the <tt><font
      FACE="Courier">SPEEchSDK\BIN</font></tt> folder that was created when you installed the 
      Speech SDK. </p>
    </blockquote>
    </td>
  </tr>
</table>
</center></div>

<p>The <tt><font FACE="Courier">GRAMCOMP.EXE</font></tt> program is a command-line 
application with no defined window. To run the program, open an MS-DOS window and move to 
the directory that contains the <tt><font FACE="Courier">GRAMCOMP.EXE</font></tt> file. 
Then type the following on the command line: </p>

<blockquote>
  <tt><font FACE="Courier"><p>gramcomp /ansi mall.txt mall.grm&lt;return&gt; <br>
  </font></tt></p>
</blockquote>
<div align="center"><center>

<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
  <tr>
    <td><b>Warning</b></td>
  </tr>
  <tr>
    <td><blockquote>
      <p>If you are using WinNT, do not include the <tt><font FACE="Courier">/ansi</font></tt> 
      portion of the command. This is needed only for Win95 workstations that do not support the 
      default Unicode compilation mode. </p>
    </blockquote>
    </td>
  </tr>
</table>
</center></div>

<p>You may need to include the directory path to locate the <tt><font FACE="Courier">MALL.TXT</font></tt> 
file. Once the compiler is running, it will read in the <tt><font FACE="Courier">MALL.TXT</font></tt> 
file and compile it into binary format and save it as <tt><font FACE="Courier">MALL.GRM</font></tt>. 
Your screen should look something like the one in Figure 18.2. </p>

<p><a HREF="f18-2.gif"><b>Figure 18.2 : </b><i>Compiling the MALL grammar.</i></a> </p>

<p>You should get a message telling you that one rule has been exported (<tt><font
FACE="Courier">Start</font></tt>). If you receive error messages, return to the <tt><font
FACE="Courier">MALL.TXT</font></tt> file to fix them and recompile. Once you complete 
compilation successfully, you are ready to test your grammar using <tt><font
FACE="Courier">SRTEST.EXE</font></tt>. </p>

<h3><a NAME="LoadingandTestingSAPIContextFreeGr">Loading and Testing SAPI Context-Free 
Grammars</a></h3>

<p>You can test your new grammar by loading it into the <tt><font FACE="Courier">SRTEST.EXE</font></tt> 
application that ships with the Speech SDK. The ANSI version of the program can be found 
in the <tt><font FACE="Courier">SPEEchSDK\BIN\ANSI.API</font></tt>. You can find the 
Unicode version in <tt><font FACE="Courier">\SPEEchSDK\BIN\UNICODE.API</font></tt>. </p>

<p>Once you load the grammar, you can use the same software to test the SR engine's 
response to your spoken queries. </p>

<h4>Loading and Activating the <tt><font FACE="Courier">MALL</font></tt> grammar</h4>

<p>When you first start the program, press the <tt><font FACE="Courier">Add Mode</font></tt> 
button to select an engine mode. You should then see one or more modes available. It does 
not matter which one you pick as long as it supports the same language you used to build 
the grammar (see Figure 18.3). </p>

<p><a HREF="f18-3.gif"><b>Figure 18.3 : </b><i>Selecting an SR mode.</i></a> </p>

<p>After selecting the SR mode, you need to load the new <tt><font FACE="Courier">MALL.GRM</font></tt> 
file. To do this, press the <tt><font FACE="Courier">Rescan Files</font></tt> button and 
enter the directory path that contains the <tt><font FACE="Courier">MALL.GRM</font></tt> 
grammar file (see Figure 18.4). </p>

<p><a HREF="f18-4.gif"><b>Figure 18.4 : </b><i>Loading the MALL.GRM grammar file.</i></a> </p>

<p>You will see the <tt><font FACE="Courier">MALL.GRM</font></tt> file appear in the list 
of available grammars. Double-click the name to load it into the SR engine. </p>

<p>Next, you need to activate the <tt><font FACE="Courier">MALL</font></tt> grammar. To do 
this, select the <tt><font FACE="Courier">Grammar</font></tt> option button on the left 
side of the screen and bring up the <tt><font FACE="Courier">ISRGramCom</font></tt> tab of 
the form. Set the Rule combo box to <tt><font FACE="Courier">Start</font></tt> and the 
Window combo box to <tt><font FACE="Courier">MainWnd</font></tt> and press <tt><font
FACE="Courier">Activate</font></tt>. The <tt><font FACE="Courier">MALL.GRM</font></tt> 
grammar should activate, and your screen should look like the one in Figure 18.5. </p>

<p><a HREF="f18-5.gif"><b>Figure 18.5 : </b><i>Activating the MALL grammar.</i></a> </p>

<p>The status box at the bottom of the form should contain messages like the ones in 
Listing 18.20. </p>

<hr>

<blockquote>
  <b><p>Listing 18.20. Messages showing successful grammar activation. <br>
  </b></p>
</blockquote>

<blockquote>
  <tt><font FACE="Courier"><p>Grammar object created successfully. <br>
  Grammar mall.grm activated, hwnd: c0c, pause: False, rule: Start,</font></tt> </p>
</blockquote>

<hr>

<h4>Testing the <tt><font FACE="Courier">MALL</font></tt> Grammar </h4>

<p>You are now ready to test the grammar by speaking to your system. The responses will 
appear in the status box at the lower left of the form. </p>

<p>For example, ask your system the following question: <i>How can I find Sears?</i> You 
should see the application flash a few status messages across the bottom of the screen and 
then return with the selected response. The message in the lower portion of the screen 
should look like the one in Figure 18.6. </p>

<p><a HREF="f18-6.gif"><b>Figure 18.6 : </b><i>Testing the MALL grammar.</i></a> </p>

<p>You can experiment with the grammar by speaking phrases and watching the response. You 
can also make changes to your <tt><font FACE="Courier">MALL.TXT</font></tt> file and 
recompile it to add new features or refine the grammar to meet your needs. </p>

<h2><a NAME="InternationalPhoneticAlphabet"><font SIZE="5" COLOR="#FF0000">International 
Phonetic Alphabet</font></a></h2>

<p>The Unicode versions of the SAPI model can support the use of the International 
Phonetic Alphabet (IPA) to aid in the analysis and pronunciation of words. The IPA is a 
standardized set of symbols for documenting phonemes. </p>

<p>On IPA-supported TTS systems, the IPA values can be used to adjust the pronunciation of 
troublesome words. This is done by associating the Unicode strings with the word in the 
dictionary. Some TTS engines will store this set of IPA codes as a permanent part of the 
dictionary. In this way, the TTS system can be refined over time to handle difficult 
words. </p>
<div align="center"><center>

<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
  <tr>
    <td><b>Note</b></td>
  </tr>
  <tr>
    <td><blockquote>
      <p>Since the IPA system is only supported through Unicode, Win95 systems do not support 
      the IPA. You can check for IPA support on WinNT-based speech systems by inspecting the <tt><font
      FACE="Courier">TTSMODEINFO</font></tt> structure of TTS engines and the <tt><font
      FACE="Courier">ILexPronounce</font></tt> interface of the SR engine. </p>
    </blockquote>
    </td>
  </tr>
</table>
</center></div>

<p>SR systems that support IPA will allow users to enter IPA codes into the SR lexicon as 
a way of teaching the system how some words will sound. These IPA values are then used to 
match audio input to words in the SR engine's vocabulary, thereby improving recognition 
performance. </p>

<p>The IPA defines a common set of English consonants and vowels along with a more complex 
set of phoneme sets that are used to further describe English language sounds. Table 18.4 
shows the list of IPA consonants and vowels with their associated Unicode values.<br>
</p>

<p align="center"><b>Table 18.4. IPA consonants and vowels.</b> </p>
<div align="center"><center>

<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
  <tr>
    <td><p align="center"><i>Consonant</i></td>
    <td WIDTH="156"><i>Examples</i> </td>
    <td WIDTH="144"><p align="center"><i>Unicode values</i></td>
  </tr>
  <tr>
    <td WIDTH="145"><p align="center">b</td>
    <td WIDTH="156">big, able, tab </td>
    <td WIDTH="144"><p align="center">U+0062</td>
  </tr>
  <tr>
    <td WIDTH="145"><p align="center">ch</td>
    <td WIDTH="156">chin, archer, march </td>
    <td WIDTH="144"><p align="center">U+0074 U+0283</td>
  </tr>
  <tr>
    <td WIDTH="145"><p align="center">d</td>
    <td WIDTH="156">dig, idea, wad </td>
    <td WIDTH="144"><p align="center">U+0064</td>
  </tr>
  <tr>
    <td WIDTH="145"><p align="center">f</td>
    <td WIDTH="156">fork, after, if </td>
    <td WIDTH="144"><p align="center">U+0066</td>
  </tr>
  <tr>
    <td WIDTH="145"><p align="center">g</td>
    <td WIDTH="156">gut, angle, tag </td>
    <td WIDTH="144"><p align="center">U+0261</td>
  </tr>
  <tr>
    <td WIDTH="145"><p align="center">h</td>
    <td WIDTH="156">help, ahead, hotel </td>
    <td WIDTH="144"><p align="center">U+0068</td>
  </tr>
  <tr>
    <td WIDTH="145"><p align="center">j</td>
    <td WIDTH="156">joy, agile, edge </td>
    <td WIDTH="144"><p align="center">U+0064 U+0292</td>
  </tr>
  <tr>
    <td WIDTH="145"><p align="center">k</td>
    <td WIDTH="156">cut, oaken, take </td>
    <td WIDTH="144"><p align="center">U+006B</td>
  </tr>
  <tr>
    <td WIDTH="145"><p align="center">l</t

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -