Voice Extreme™ Toolkit

877 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
877
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Voice Extreme™ Toolkit

  1. 1. Voice Extreme™ Toolkit Programmer’s Manual With Sensory Speech 6 Technology © 2002 Sensory, Inc. P/N 80-0200-D
  2. 2. Voice Extreme™ Toolkit Programmer’s Manual Contents Overview................................................................................................................................................................. 4 The Development Environment ........................................................................................................................... 5 The Editor...................................................................................................................................................................... 6 The Project Manager ..................................................................................................................................................... 8 Programmer .................................................................................................................................................................. 9 Program Options ......................................................................................................................................................... 10 Error Management ...................................................................................................................................................... 12 Debugging Terminal .................................................................................................................................................... 13 Folder Structure........................................................................................................................................................... 14 Commands .................................................................................................................................................................. 15 File Menu ......................................................................................................................................................... 15 Edit Menu......................................................................................................................................................... 15 View Menu ....................................................................................................................................................... 15 Macros Menu ................................................................................................................................................... 16 Project Menu.................................................................................................................................................... 16 Tools Menu ...................................................................................................................................................... 17 Window Menu .................................................................................................................................................. 17 Help Menu........................................................................................................................................................ 17 Toolbar............................................................................................................................................................. 17 Taskbar ............................................................................................................................................................ 17 Statusbar.......................................................................................................................................................... 17 Sample Projects .................................................................................................................................................. 18 Speaker Independent (sidemo.vep) ............................................................................................................................ 18 Speaker Independent Math (simath.vep) .................................................................................................................... 18 Continuous Listening (clsi.vep).................................................................................................................................... 18 Speaker Dependent Sfx (sdsfx.vep) ............................................................................................................................ 19 Speaker Verification (svdemo.vep).............................................................................................................................. 19 Word Spot (wsdemo.vep) ............................................................................................................................................ 19 Record and Play (rpdemo.vep).................................................................................................................................... 20 Touch Tones (ttones.vep)............................................................................................................................................ 20 Music (music.vep) ....................................................................................................................................................... 20 Voice Extreme™ Development Board............................................................................................................... 21 Voice Extreme™ Module............................................................................................................................................. 24 Creating Your First Voice Extreme™ Project ................................................................................................... 28 Creating a ‘Hello World’ Program ................................................................................................................................ 28 Creating the Project ......................................................................................................................................... 28 Building the Project .......................................................................................................................................... 28 Downloading .................................................................................................................................................... 29 Extending the ‘Hello World’ Program (add a blinking LED feature) ............................................................................. 29 Creating a Speaker Independent (SI) Sample Program. ............................................................................................. 30 Creating a Speaker Dependent (SD) Sample Program. .............................................................................................. 31 Voice Extreme™ Language: VE-C Introduction ............................................................................................... 34 VE-C/ANSI C comparison ........................................................................................................................................... 34 VE-C Data Types ........................................................................................................................................................ 36 Standard Data Types ....................................................................................................................................... 36 Built-in Sensory Data Types............................................................................................................................. 36 Derived Data Types ......................................................................................................................................... 37 Storage Options for the Data Types................................................................................................................. 38 VE-C Language........................................................................................................................................................... 39 Functions, Blocks, Statements and Expressions ............................................................................................. 39 Operators ......................................................................................................................................................... 39 Control Statements .......................................................................................................................................... 41 Functions, Calls and Returns ........................................................................................................................... 43 Preprocessor Features .................................................................................................................................... 44 Using the Sensory Technologies: Common Issues ..................................................................................................... 45 Output Devices ................................................................................................................................................ 45 Jumpout Output ............................................................................................................................................... 45 Debug Output................................................................................................................................................... 46 Technology Configuration ................................................................................................................................ 46 Accessing Multiple Results .............................................................................................................................. 46 Using the Sensory Technologies: Specific Examples.................................................................................................. 46 Speech Synthesis ............................................................................................................................................ 46 2 P/N 80-0200-D © 2002 Sensory Inc.
  3. 3. Programmer’s Manual Voice Extreme™ Toolkit Pattern Generation........................................................................................................................................... 47 Speaker Independent Speech Recognition...................................................................................................... 48 Speaker Dependent Speech Recognition ........................................................................................................ 48 Speaker Verification......................................................................................................................................... 49 Continuous Listening ....................................................................................................................................... 50 WordSpot ......................................................................................................................................................... 50 Record and Play .............................................................................................................................................. 51 TouchTones (DTMF)........................................................................................................................................ 52 Music ............................................................................................................................................................... 52 Other Voice Extreme™ Built-In functions......................................................................................................... 52 Debugging and Troubleshooting Tips.......................................................................................................................... 53 Debugging Functions and Macros ................................................................................................................... 53 Run-time Error Checking and Reporting .......................................................................................................... 53 Error Messages from the Parser ...................................................................................................................... 53 Voice Extreme™ Data Files ........................................................................................................................................ 54 Sentence Table Format ................................................................................................................................... 54 Speech File ...................................................................................................................................................... 57 Weights file ...................................................................................................................................................... 57 Music file .......................................................................................................................................................... 57 Voice Extreme™ Language: VE-C Built-in Functions ..................................................................................... 58 Technology Configuration............................................................................................................................................ 58 Speech Synthesis........................................................................................................................................................ 60 Pattern Generation ...................................................................................................................................................... 61 Speaker Independent Recognition .............................................................................................................................. 65 Speaker Dependent Recognition................................................................................................................................. 69 Speaker Verification .................................................................................................................................................... 76 Continuous Listening ................................................................................................................................................... 80 WordSpot .................................................................................................................................................................... 83 Record and Play.......................................................................................................................................................... 85 DTMF .......................................................................................................................................................................... 88 Music ........................................................................................................................................................................... 89 Serial (RS-232) Communication.................................................................................................................................. 90 Debug Output .............................................................................................................................................................. 93 I/O ............................................................................................................................................................................... 94 Keypad Functions........................................................................................................................................................ 96 Timing Functions ......................................................................................................................................................... 98 Utility Functions ......................................................................................................................................................... 100 Serial Packets Overview ................................................................................................................................... 104 Serial Packets Implementation .................................................................................................................................. 104 Disclaimer .......................................................................................................................................................... 105 Voice Extreme™ Toolkit Limited Warranty..................................................................................................... 105 SENSORY Software End User License Agreement ....................................................................................... 106 The Interactive Speech™ Product Line .......................................................................................................... 108 © 2002 Sensory Inc. P/N 80-0200-D 3
  4. 4. Voice Extreme™ Toolkit Programmer’s Manual Overview Voice Extreme™ Integrated Development Environment (IDE) allows quick development of application programs using Sensory Speech™ technologies. Voice Extreme allows a developer to write the application program in a higher-level “C-like” language on a PC, accessing the Sensory Speech technologies through calls to “built-in” functions. The Voice Extreme™ package streamlines development by: Allowing programs to be written in VE-C, a commonly used higher level language very similar to ANSI C Allowing a simple means of linking the program and the data files it requires Providing access to technology functions in a manner that conceals many of the details Providing access to hardware features such as I/O ports, timers and an RS-232 interface Providing a set of “header” files that define commonly used VE-C macros and constants This help file provides an introduction to the process of developing a Voice Extreme™ application, the Voice Extreme™ language (VE-C) and its data types, Sensory technologies and the Voice Extreme™ IDE software. The Voice Extreme™ Toolkit contains: Voice Extreme™ Development Board Voice Extreme™ Module Power supply (may be an option) Serial cable for PC RS-232 connection Quick Start Guide Software CD containing the Voice Extreme™ IDE, Quick Synthesis™, sample projects, sample data files and documentation 4 P/N 80-0200-D © 2002 Sensory Inc.
  5. 5. Programmer’s Manual Voice Extreme™ Toolkit The Development Environment Voice Extreme™ IDE is the development environment for creating VE-C applications. It is composed of the following modules: Editor with syntax coloring, macro generation, bookmarks, line reminders and other utilities Project Management and Project Editing Debug and parsing of errors Single button builder that parses, assembles, links and checks the project Programmer Toolbars Utilities Include most important commands that can be selected from the menus Working Area This is the working area where all windows are shown. You can move, resize, maximize or iconize each window. Using the Windows Menu you can also cascade, horizontally tile or vertically tile all windows. Statusbar Taskbar Shows a description of Displays an icon and title for each open each menu item window. Click on an icon to activate the associated window. You also can find a list of all open windows in the Window Menu © 2002 Sensory Inc. P/N 80-0200-D 5
  6. 6. Voice Extreme™ Toolkit Programmer’s Manual The Editor Voice Extreme™ IDE is equipped with an editor which has been specially developed for this VE-C language, but can also be used for standard ANSI C. Bookmark Line reminder Vertical window splitter Horizontal window splitter Document Toolbar The main features are: Syntax coloring Bookmarks Line reminders Line numbering Vertical/horizontal split Tabs customization “Auto-Indent” function Case control Search and replace function Macros Multi Undo and Redo function Text selection: free, word, row, column and full document Copy, cut and paste functions Printing of the full document or of the selected text Color or black & white printing Line number printing Note that a pop-up menu can be activated by clicking the right mouse button on the editor window. This menu contains all main editor functions. 6 P/N 80-0200-D © 2002 Sensory Inc.
  7. 7. Programmer’s Manual Voice Extreme™ Toolkit The “Document Toolbar” contains some editor functions. Save (CTRL-S) Save the document. Parse (F12) Parse the document (.VEC) - very useful for checking errors without running the complete Build Process. Assemble (CTRL-F12) Assemble the Sentence Table source (.VEA). Toggle bookmark (F5 or Mouse Left Button click on the left margin of the document) Toggle a bookmark on/off. The bookmarks feature allows the programmer to mark one or more lines, and to move quickly between them. They are represented by a light blue highlighting of line number. Go to previous bookmark (CTRL-UP) Move the cursor to the previous bookmark. Go to next bookmark (CTRL-DOWN) Move the cursor to the next bookmark. Clear all bookmarks (CTRL-F5) Clear all bookmarks. Toggle line reminder (F6 or Mouse Right Button click on the left margin of the document) Toggle a line reminder on/off. Unlike bookmarks, “Line Reminders” are used only for marking a line, and you cannot browse them. They are represented by a small yellow mark near the line number. Note that you can mark a line with both a Bookmark and a Line Reminder. Clear all line reminders (CTRL-F6) Clear all line reminders. Toggle Error List Toggle on/off the Error List. Move cursor (go to…) Input the desired values in the Row and Col fields, then press this button, this will cause the cursor to move. © 2002 Sensory Inc. P/N 80-0200-D 7
  8. 8. Voice Extreme™ Toolkit Programmer’s Manual The Project Manager The “Project Manager” enables creation and editing of projects prior to compiling and linking. Each project can contain only one source document (unlimited number of includes) and all desired data files (speech, sentence table, weights and music). For documentation purposes, there is a window that describes the project. Toolbar Project file list Project description Horizontal splitter The following commands are available: Add document Use this button to add the main source to the project. Add Speech Use this button to add one or more speech files to the project. Add Sentence Table Use this button to add one or more sentence table files to the project. Add Weights Use this button to add one or more weights files to the project. Add Music Use this button to add one or more music files to the project. Remove Use this button to remove the selected file from the project. Details Use this button to show details of the selected file (name, path, size, etc.). Rename the project Use this button to rename the project. Save the project Use this button to save the project. Note that it is enabled only if the project has been modified. Note that a pop-up menu can be activated by clicking the right mouse button on the file list. This menu contains all main project functions. 8 P/N 80-0200-D © 2002 Sensory Inc.
  9. 9. Programmer’s Manual Voice Extreme™ Toolkit Programmer The Programmer has been implemented to allow more flexible and quicker programming of Voice Extreme™ Modules. To show or hide the Programmer window, go to “Tools” then “Voice Extreme Programmer”. Toolbar Binary file details To load the binary file (.VEB), click on the “Load binary file” button. Next, start the download process with the “Start download” button. © 2002 Sensory Inc. P/N 80-0200-D 9
  10. 10. Voice Extreme™ Toolkit Programmer’s Manual Program Options The Options window allows personalization of the program. Press "Ok" to save all changes and “Cancel” to ignore them. Sections Save and exit Ignore changes Section: Editor Syntax color and style The integrated editor recognizes programming syntax, and allows syntax-sensitive text color and style customization. The following syntax types are supported: Number, Symbol, String, Comment, Preprocessor block, Character, Language reserved words, VE built-in functions, VE macros and VE Constants. First, select the desired syntax group. For each group, use “Fore” (foreground color) and “Back” (background color) sliders to select text color, and “N” (normal), “B” (bold) and “I” (italic) buttons for the style. Tab size and char The tab size can vary from 2 to 22 characters. If you want to replace the tab with the same number of space characters, disable the option “Use tab char”. Auto-indent Enables the auto-indent function. Margin Disable this option to hide the gray margin on the left side of the editor window that contains row numbers, bookmarks and line reminders. In this mode, bookmarks and line reminders will be indicated by row color and not as symbols. Line numbers Displays line numbers. Section: Print Page header A customized header may be printed at the top of each page by entering text in the window and checking the “Enable” option. Page footer A customized footer may be printed at the top of each page by entering text in the window and checking the “Enable” option. Note that the text you enter will be centered on the page, with the document name on the left and the page number on the right. Use syntax colors Enables color printing (the colors correspond to those set in the editor). Print line numbers Enables printing of line numbers. 10 P/N 80-0200-D © 2002 Sensory Inc.
  11. 11. Programmer’s Manual Voice Extreme™ Toolkit Section: Tools Includes folder (VEinclude) (Builder) This is the file path for included files. The parser will search this folder any included files with #include <filename.veh>. Note that if the file to be included is in the same folder as the document, use #include “filename.veh”. Close Build window automatically (Builder) Enable this option if you want the Build window to close automatically at the end of the process. If there are errors, the window will remain open so that you can review them. Serial port (Programmer) This parameter sets the number of the serial port that is connected to the development board. Close Download window automatically (Programmer) Enable this option if you want the Build window to close automatically at the end of the process. If there are errors, the window will remain open so that you can review them. Section: Application Project default folder In this text box you can specify the default project folder where Voice Extreme™ IDE will store your projects (to browse, click the folder icon on the right). Action performed at application startup This parameter allows certain actions to be performed automatically upon each launch of the Voice Extreme™ IDE: - No action - Create a new document - Load last document - Load last project / Load main source when project is loaded Make a backup copy Enable this parameter to create a backup copy (.BAK) of each saved document or project. © 2002 Sensory Inc. P/N 80-0200-D 11
  12. 12. Voice Extreme™ Toolkit Programmer’s Manual Error Management During the Build or Parse process all parser errors are shown in the bottom of the editor window (see image below). Editor Splitter Error List An error list appears automatically if errors occur. The error report includes: line number, error type and description. Clicking on an error will cause the cursor to be positioned on corresponding line of code. The line will be highlighted depending on the class of error: red (error) or yellow (warning). When editing is resumed on the line containing the error, the highlighting will disappear. The error list can be toggled on/off using the button or resized moving the splitter up/down. 12 P/N 80-0200-D © 2002 Sensory Inc.
  13. 13. Programmer’s Manual Voice Extreme™ Toolkit Debugging Terminal The Debugging Terminal can be used to receive debug data over the serial port from a Voice Extreme™ application that uses the Debug Output functions (see Debug Output section). The Debugging terminal is very easy to use, just open it and press the “Open Connection” button. This makes the terminal ready to receive data. Note that during the Download process, the terminal connection will be temporary closed until the process ends. © 2002 Sensory Inc. P/N 80-0200-D 13
  14. 14. Voice Extreme™ Toolkit Programmer’s Manual Folder Structure After a successful installation of Voice Extreme™ IDE, you will find the following folder structure (usually under "c:Program Files" folder, but may vary depending on Windows localization): Sensory This is the main folder where all Sensory programs are installed. VoiceExtreme All program files are stored in this folder. Bin This folder contains all executables used by the build process. Docs This folder contains the Voice extreme™ Documentation. Samples This is the default folder for storing project files. SamplesCoach This folder contains the new “Coach Extreme” sample project. SamplesSource This folder contains all example project sources. SamplesDataMusic This folder contains all sample music files. SamplesDataSpeech This folder contains all sample speech music files. SamplesDataWeights This folder contains all sample weights sets plus some extra weights in English, German (DemoSI) and Japanese (DemoSI). Include This is the default include folder (VEinclude). Note the ‘ve.veh’ file is located in this folder. IncludeSpeech This folder contains all speech include files. IncludeWeights This folder contains all weights include files. Note that the sample files are provided for demonstration purposes only. They are not intended for use in final products and such use is strictly prohibited. 14 P/N 80-0200-D © 2002 Sensory Inc.
  15. 15. Programmer’s Manual Voice Extreme™ Toolkit Commands File Menu The “File Menu” contains all commands to manage a document (new, load, save, print, etc.) as well as a list of the last five viewed documents. New… Use this button to create a new document ("untitled.vec"). There are three options: Empty document (CRTL-N) Standard Voice Extreme™ document (CTRL-SHIFT-N) Standard Sentence Table document Open… (CTRL-O) Load a document. Save (CTRL-S) Save the current document. Save as… Save the document under a different name. Print… (CTRL-P) Print the entire document or the selected text. Exit Close the Voice Extreme™ IDE program. Edit Menu The “Edit Menu” contains commands to manage the text (copy, cut, paste, select, etc.) as well as the standard “Search” and “Replace”. Undo (CTRL-Z) Undo the last edit. Redo (CTRL-Y) Redo the last edit. Copy (CTRL-C or CTRL-INS) Copy selected text to the clipboard. Cut (CTRL-X or SHIFT-CANC) Delete selected text and copy it to the clipboard. Paste (CTRL-V or SHIFT-INS) Paste the clipboard contents into the document. Select line (CTRL-L) Select an entire line of text. Select all (CTRL-A) Select the entire document. Find (CTRL-F) Show the standard “Search text” window. Find next (F3) Repeat the last search. Replace (F4) Search and replace text. View Menu The “View menu” allows toolbars to be shown or hidden. In addition, details of the current document as well as the Option window can be displayed. Document Toolbar Show/hide the document toolbar. Project Toolbar Show/hide the Project toolbar. © 2002 Sensory Inc. P/N 80-0200-D 15
  16. 16. Voice Extreme™ Toolkit Programmer’s Manual Bookmarks Toolbar Show/hide the Bookmarks toolbar. Debug Toolbar Show/hide the Debug toolbar. Application Toolbar Show/hide the Application toolbar. Tools Toolbar Show/hide the Tools toolbar. Taskbar Show/hide the Taskbar. Status Bar Show/hide the Status bar. Document details (CTRL-D) Show all document details (name, path, size, etc.). Macros Menu The “Macro Menu” can be used to paste commonly used code blocks into the document. Note that the Macro will replace any selected text. Document header Import the standard document header. Comment separator (line) (CTRL-SHIFT-L) Import the standard line separator. Comment block (CTRL-SHIFT-B) Import a comment block. Note that unlike other macros, this one does not replace the selected text, but places it between the start (/*) and end (*/) comments. Main () Import the main() block. If (CTRL-SHIFT-I) Import the if() statement. If…Else (CTRL-SHIFT-E) Import the if() else statement. While (CTRL-SHIFT-W) Import the while() statement. Do…While (CTRL-SHIFT-D) Import the do while() statement. Switch…case (CTRL-SHIFT-C) Import the switch case statement. #Include <…> Import the standard #include statement. Note that before importing this macro you will be prompted to select the file to be included. The file path will be inserted between “<” and “>”, which becomes necessary when the file to be included is in a different folder. #Include <ve.veh> Import the standard #include <ve.veh> statement. Project Menu The “Project Menu” contains all commands for Project management (new, load, save, build, etc.) as well as a list of the last five viewed documents. New… (CTRL-SHIFT-N) Create a new project ("untitled.vep") Open… (CTRL-SHIFT-O) Load a project. Save (CTRL-SHIFT-S) Save the current project. 16 P/N 80-0200-D © 2002 Sensory Inc.
  17. 17. Programmer’s Manual Voice Extreme™ Toolkit Save as… Save the project under a different name. Build (F9) Build the current project. Download (F10) Download the project binary file (.VEB) into the Voice Extreme™ Module. Project window (F11) Show or hide the project window. Tools Menu The “Tools Menu” contains all utility commands. Quick Synthesis Launch Sensory Quick Synthesis™. This button is enabled only if Quick Synthesis™ has been installed. Debug Terminal Show the integrated Voice Extreme™ Debug Terminal. Voice Extreme™ Programmer Show the integrated Voice Extreme™ Programmer, very useful for programming multiple modules. Options… Show the program options window. Windows calculator Launch the standard Windows Calculator (calc.exe). Window Menu The “Window Menu” contains all commands necessary to manage the program windows. It also includes a dynamic list of open windows (same function as the Taskbar). Cascade Cascades all open windows. Tile horizontal Tiles all open windows horizontally. Tile vertical Tiles all open windows vertically. Arrange icons Arranges all iconized windows at the bottom of the program. Help Menu Help contents (F1) Show the Voice Extreme™ help file. Sensory web site… Launch your default browser and connect to the Sensory web site. About… Retrieve information about the software. Toolbar The Toolbar contains the most frequently used buttons from the menus. Each toolbar can be moved on the desktop or docked on the left, right, top, or bottom of the window. When you close the program, your toolbar configuration is saved. Taskbar The Taskbar shows a list of all open windows (similar to the Windows Taskbar). Statusbar The Statusbar gives you a description of menu items or any program messages. © 2002 Sensory Inc. P/N 80-0200-D 17
  18. 18. Voice Extreme™ Toolkit Programmer’s Manual Sample Projects Speaker Independent (sidemo.vep) This program demonstrates the Speaker Independent Speech Recognition technology. Operation: After an initial BEEP the program loops forever, waiting for button presses. Press Button A for a full prompt Press Button B for a short prompt. Respond to the prompt by saying one of the 6 possible words. The program tells you what word you said or announces an error. Notes: The program is linked with both a SPEECH and a WEIGHTS data file. This program calls the PatGenW and Recog functions and checks their returns. It illustrates the use of the confidence level stored in the WEIGHTS file and special processing for NOTA (None Of The Above) recognition. Files: sidemo.vec (source) sidemo.ves (speech) si6.vew (weights) Speaker Independent Math (simath.vep) This program demonstrates the Speaker Independent speech Recognition technology, using the Prior function for emphasizing the correct answer in a weight set. Operation: After an initial BEEP the program loops forever, waiting for user to press Button A. When the button is pressed, the program generates a random math problem, asks it and waits for an answer. If the answer has a low confidence level, the program re-prompts for confirmation, and then announces the final Correct/Incorrect result. Note: This program illustrates the use of more than one weight set, using Prior to emphasize the right answer, accessing the multiple results from recognition and using them to re-prompt for confirmation. Files: simath.vec (source) simath.ves (speech) noyes.vew (weights) digits.vew (weights) Continuous Listening (clsi.vep) This program demonstrates Continuous Listening used with the Speaker Independent technology. Operation: The program loops forever, waiting for the user to say "Place call" and beeps at the beginning of each loop. It lights the green LED to signal that it is "ready" for the first word, the red LED when it is "busy" processing either word, and the yellow LED to signal that it is "triggered" for the 2nd word. It lights all of the LEDs to signal that it is "activated"; i.e. it has recognized both words. It also announces "Sensory Powered". If any PatGen or Recognition error condition occurs, the program beeps and waits again for "Place call". Note: This program illustrates the use of the confidence levels stored in the weights file and the use of word durations to speed rejection of inappropriate words. It also can be edited to show the effects of the different MicDistances. Files: clsi.vec (source) sensopow.ves (speech) sidemo.ves (speech) cldemoa.veo (sentence table) place.vew (weights) call.vew (weights) 18 P/N 80-0200-D © 2002 Sensory Inc.
  19. 19. Programmer’s Manual Voice Extreme™ Toolkit Speaker Dependent Sfx (sdsfx.vep) This program demonstrates Speaker Dependent technology. Operation: After an initial BEEP the program loops forever, waiting for button presses. Button A initiates a recognition phase, where the program prompts for a command, then attempts to recognize it and emit the corresponding sound (it Beeps if none trained). Button B initiates the training phase, where the program prompts for up to six words (e.g. FORWARD, LASER, SHIELD, TARGET, ROTATE, STOP). This phase can be aborted by pressing Button A or by not responding to the prompt for the next password (it beeps if all are trained). Button C announces all commands already trained (beeps if none trained). Notes: The program is linked with two sentence tables, one for the sound effects and one for prompts and error messages. It illustrates the use of simultaneous PatGen and Record, where the actual voice pattern for each command is saved and can be replayed. It illustrates the use of variables in Flash (non-volatile) memory, so that commands trained during one session are still available in later sessions (i.e. after a system reset). It illustrates the use of RecogSD to compare a newly trained template with others already in the set, in order to reject a command which is too similar to one already trained. The lines which actually configure and output signals in response to the various commands have been commented out, but serve as examples of how one might use such a feature. Files: sdsfx.vec (source) sddemo.ves (speech) lasers.vea (speech) sddemoa.veo (sentence table) lasersa.veo (sentence table) si6.vew (weights) Speaker Verification (svdemo.vep) This program demonstrates Speaker Verification technology. Operation: After an initial BEEP the program loops forever, waiting for button presses. The user may want to run HyperTerminal to see debug printout from the Speaker Verification process. Button A initiates a recognition phase, where the program waits for the user to say each password in order (it BEEPs if none trained). Button B initiates the training phase, where the program prompts for up to four passwords. The red LED is on during Pattern Generation. This phase can be aborted by pressing Button A or by not responding to the prompt for the next password (it BEEPs if all are trained). Button C allows the user to cycle the "level" which controls the tradeoff between false accepts and false rejects (1-5, with 5 being the strictest). Notes: This program illustrates direction of debug output to the serial port and also the need to temporarily disable the RS-232 lines during PatGen. It also uses the #pragma directives. Files: svdemo.vec (source) svdemo.ves (speech) svdemoa.veo (sentence table) Word Spot (wsdemo.vep) This program demonstrates Word Spot technology. Operation: After an initial BEEP the program loops forever, waiting for button presses. Button A initiates a recognition phase, where the program waits for the user to say each password in order (it BEEPs if none trained). The green LED comes on when the program is listening for the first word, the yellow LED comes on when the program is listening for the second. When the second word is recognized, the red LED comes on for a second. If a timeout occurs, the program double BEEPs. © 2002 Sensory Inc. P/N 80-0200-D 19
  20. 20. Voice Extreme™ Toolkit Programmer’s Manual Button B initiates the training phase, where the program prompts for up to two passwords. The red LED is on during Pattern Generation. This phase can be aborted by pressing Button A or by not responding to the prompt for the next password (it BEEPs if all are trained). Button C allows the user to cycle the "knob" which controls the tradeoff between false accepts and false rejects (1-4, with 4 being the strictest). Notes: This program illustrates the use of prompted Word Spotting (with no timeout when listening for the first word of a sequence) and non-prompted (3 second timeout when listening for the second word of the sequence). Files: wsdemo.vec (source) sddemo.ves (speech) wsdemoa.veo (sentence table) Record and Play (rpdemo.vep) This program demonstrates Record and Play technology. It illustrates the 3 compression levels (4-bit, 3-bit, 2-bit) and the amount of storage required for various lengths and compression levels of recording. Operation: After an initial BEEP the program loops forever, waiting for button presses. Button A allows you to make a single recording, which you can stop by pressing any button. The size in blocks of the recording is announced and the uncompressed recording is played. Button B allows you to compress the recording to the next level (3-bit or 2-bit). The size in blocks of the recording is announced and the compressed recording is played. Button C replays the current recording at the current compression level, announcing the level first. Notes: This demo illustrates the use of variables in Flash (non-volatile) memory, so that the compression level during one session is still available in later sessions (i.e. after a Reset). Files: rpdemo.vec (source) rpdemo.ves (speech) Touch Tones (ttones.vep) This program demonstrates DTMF technology Operation: After an initial BEEP the program loops forever, waiting for user to press Button A or B. Depending on which button is pressed, the program announces and dials a local or long distance phone number, preceded by a dial tone. Notes: This program illustrates the use of strings, pointers and "const" variables. Files: ttones.vec (source) numbers.ves (speech) Music (music.vep) This program demonstrates Music. Operation: When all LEDs are on, press one of the 3 buttons to play one of 3 tunes. The corresponding LED lights while the tune is playing. Pressing any key on the 3X4 keypad stops the current tune. Notes: The program is linked with both NOTES and TUNES, which occupy ~64K of the .veb file size. Files: music.vec (source) musicdwc.vem (music) musiclis.vem (music) 20 P/N 80-0200-D © 2002 Sensory Inc.
  21. 21. Programmer’s Manual Voice Extreme™ Toolkit Voice Extreme™ Development Board The Voice Extreme™ Development board is the larger of the two circuit boards in the Voice Extreme™ Toolkit, and provides a convenient means of interfacing the Voice Extreme™ Module with the development PC, as well as many handy “accessory” functions. The Development Board offers several features: Speaker The onboard speaker has a fixed volume and is intended for application debugging. For better audio quality, use of an external speaker with adjustable volume is recommended. Plugging an external speaker into the speaker jack will disable the onboard speaker. Prototyping Area A grid of 0.1” through-holes for use by the application developer to add external circuitry. RS-232 Port A 9-pin connector for connecting the serial cable to the development PC. I/O Port A standard 20-pin shrouded header with 0.1” centers for wiring the I/O lines from the development board to the target application. The I/O pins are initially assigned and configured as: I/O Description I/O Description P0.0 Serial port input from Host (RCV) P1.0 Button A, input, strong P/U (0=pressed) P0.1 Serial port output to Host (XMT) P1.1 Button B, input, strong P/U (0=pressed) P0.2 Unused, input, weak pull-up P1.2 Button C, input, strong P/U (0=pressed) P0.3 Unused, input, weak pull-up P1.3 Red LED, output (0=on) P0.4 Unused, input, weak pull-up P1.4 Unused, input, weak pull-up P0.5 DO NOT USE (Flash address bit A16) P1.5 Green LED, output (0=on) P0.6 DO NOT USE (Flash address bit A17) P1.6 Yellow LED, output (0=on) P0.7 Unused, input, weak pull-up P1.7 Serial port enable, output (0=off, 1=on) © 2002 Sensory Inc. P/N 80-0200-D 21
  22. 22. Voice Extreme™ Toolkit Programmer’s Manual If an application is stand alone, the two serial I/O pins, P0.0 and P0.1, and the serial port enable, P1.7, may be used for other purposes; however, programs will download via asynchronous serial I/O. Since I/O pins P0.5 and P0.6 are connected to the address bus of the Flash memory, they should not be used under any circumstances. A 4X5 Matrix Keypad is supported. When the keypad is being scanned, the columns are driven (active low) and the rows are sensed (pulled high). When the keypad is being scanned, all previous configuration and output values for these pins are saved and restored. The I/O pinouts are as follows: Pin P0.5 P1.5 P0.6 P1.6 P0.2 P0.3 1 2 3 A E P1.3 4 5 6 B F P0.4 7 8 9 C G P1.4 * 0 # D H Voice Extreme™ Module The Voice Extreme™ (VE) module is the heart of the Voice Extreme™ system, and is intended to be removed from the Development Board and wired into the target application. Microphone As with the speaker, the onboard microphone is intended for application debugging. In an actual product, the microphone should be mounted in a location that is convenient for the user and will result in the highest possible signal-to-noise ratio. Plugging an external microphone into the external microphone jack will disable the onboard microphone. Power Jack A 2.1mm jack for connecting the external wall-mount power supply. Power regulation is provided on the development board. Polarity of the connector is indicated on the silkscreen of the printed circuit board. External Speaker Jack Accepts speakers with stereo or mono 3.5mm plugs. Stereo speakers will only play out of one speaker. This output is intended to drive 8-ohm speakers, and provides up to 350 mW of power. External Microphone Jack Accepts microphones with stereo or mono 3.5mm plugs. Reset Switch Hardware reset of the VE Module. Download Switch Places the VE Module in a state such that it is waiting for a program to be downloaded from the development PC. Switch A, B and C Tactile momentary button available for use by the application developer. Led 1, 2 and 3 Green, Yellow and Red LEDs available for use by the application developer. Power Led A green LED indicating power has been connected to the board. 22 P/N 80-0200-D © 2002 Sensory Inc.
  23. 23. Programmer’s Manual Voice Extreme™ Toolkit © 2002 Sensory Inc. P/N 80-0200-D 23
  24. 24. Voice Extreme™ Toolkit Programmer’s Manual Voice Extreme™ Module The Voice Extreme™ (VE) module is the heart of the Voice Extreme™ system, and is intended to be removed from the Development Board and wired into the target application. The VE module offers several features: Mounting Hole Four mounting holes are provided for secure mechanical connections in mounting the module in an application. When the module header connector is used to connect the module to another board, the mounting holes are normally not required. Module Connector A standard header with 0.1” centers to carry signals between the Development Board and the Module. VE IC The Voice Extreme™ Integrated Circuit (VE IC) is the central speech processor. Please refer to the Voice Extreme™ IC Datasheet for a detailed specification. VE ROM This 64KB OTP ROM contains the VE interpreter and the speech technology code. If the VE IC is purchased from Sensory, the VE interpreter and speech technology code are masked into an internal ROM on the VE IC. In this case, the external ROM is not required. Microphone Gain Resistor An optional microphone resistor may be added to the VE module. From the factory, the microphone gain is pre- set to a level suitable for arms-length user interfaces. An application note is available for selecting a gain resistor for other applications. Osc 1 Crystal A 14.318 MHz crystal used to establish the frequency of Timer 1 on the VE IC. Timer 1 is used for all speech recognition functions. Osc 2 Crystal A 32.768 KHz crystal used to establish the frequency of Timer 2 on the VE IC. Timer 2 is useful for timekeeping applications since it is not interrupted, unlike Timer 1. Note that Timer 2 is not available on the TQFP versions of the VE IC. 2MB Flash Memory This memory is required on the VE module and all VE applications. Due to the powerful dynamic memory handler of VE system software, this Flash is designed to store the application code, speaker independent weight sets, speech templates, record and playback data, program data, and music data. 24 P/N 80-0200-D © 2002 Sensory Inc.
  25. 25. Programmer’s Manual Voice Extreme™ Toolkit Voice Extreme™ Module Connector A standard 34-pin header with 0.1" centers to carry signals between the Development Board and the Voice Extreme™ module. This header has pins on 0.1” centers, and interfaces the VE module with the Development Board. It is referenced as J3 on the Development Board and J1 on the VE Module. Pin Description Pin Description Pin Description 1 GND 13 DOWNLOAD 25 P1.0 2 GND 14 RESET 26 P1.1 3 GND 15 VDD 27 P1.2 4 MIC-IN 16 PDN 28 P1.3 5 N.C. 17 P0.0 Serial port input from Host (RCV) 29 P1.4 6 DAC-OUT 18 P0.1 Serial port output to Host (XMT) 30 P1.5 7 GND 19 P0.2 31 P1.6 8 GND 20 P0.3 32 P1.7 Serial port enable, output (0=off, 1=on) 9 AUDIO-RET 21 P0.4 33 GND 10 AUDIO-OUT 22 P0.5 DO NOT USE (Flash address bit A16) 34 PND 11 PWM0 23 P0.6 DO NOT USE (Flash address bit A17) 12 PWM1 24 P0.7 Note, when designing your own hardware, note that the above table references the VE Module (NOT the development board). Note also that if an application is stand alone, the two serial I/O pins, P0.0 and P0.1, and the serial port enable, P1.7, may be used for other purposes; however, programs will download via asynchronous serial I/O. Since I/O pins P0.5 and P0.6 are connected to the address bus of the Flash memory, they should not be used under any circumstances. A 4X5 Matrix Keypad is supported. When the keypad is being scanned, the columns are driven (active low) and the rows are sensed (pulled high). When the keypad is being scanned, all previous configuration and output values for these pins are saved and restored. The I/O pinouts are as follows: Pin P0.5 P1.5 P0.6 P1.6 P0.2 P0.3 1 2 3 A E P1.3 4 5 6 B F P0.4 7 8 9 C G P1.4 * 0 # D H © 2002 Sensory Inc. P/N 80-0200-D 25
  26. 26. Voice Extreme™ Toolkit Programmer’s Manual 26 P/N 80-0200-D © 2002 Sensory Inc.
  27. 27. Programmer’s Manual Voice Extreme™ Toolkit Getting Started What is a Voice Extreme™ Application? Before we get started, you may find it helpful to review an overview of the Voice Extreme System. (If you just want to get going, you can safely skip to Creating Your First Voice Extreme™ Project). A Voice Extreme™ application consists of a program file plus any data files it needs, linked together into a binary image file that can be downloaded to a 2Mbyte flash data memory. This program is then executed by the Voice Extreme™ interpreter, which runs in program memory built in to the VE IC. Please refer to the Voice Extreme Manual for a more detailed explanation and example code. Voice Extreme™ data files are described in detail in the “Voice Extreme™ Data Files” section of the Help file. They consist of: Speech synthesis files, also known as vocabulary tables (.VES file) Speech sentences files (.VEO files) Weights files, for use with Speaker Independent recognition (.VEW file) Notes and tunes files, for use with the Music technology (.VEM file) Most programs begin with a series of statements that define, and optionally initialize, the data used by the program. VE-C allows both standard C data types and built-in data types specifically designed for use with the Sensory technologies. Data types used by Voice Extreme™ applications include: Integers for use as counters, indices, error codes Characters and strings of characters for messages Boolean, or true/false, variables to control program flow Templates (and arrays of templates) for use with Sensory recognition Built-in Sensory data types (SPEECH, SENTENCES, WEIGHTS, NOTES, TUNES) contained in data files and linked together with Voice Extreme™ programs The data declarations are followed by a series of control statements that define the program flow. The Voice Extreme™ language, VE-C, is very similar to ANSI-standard C. The following types of statements are available: Assignment of values to variables Arithmetic and logical operations on variables Looping (for, while, do…while) Branching (if…else, switch…case, goto) Calls to built-in functions that access Sensory technologies and system resources © 2002 Sensory Inc. P/N 80-0200-D 27
  28. 28. Voice Extreme™ Toolkit Programmer’s Manual Creating Your First Voice Extreme™ Project No C manual would be complete without a “hello world” example. We will build a sample application that speaks “hello world” and runs on the Voice Extreme™ Toolkit. To build our application: Create a document Create a project Build the project Download the project to flash memory on the VE module Note that we need a vocabulary containing one phrase, “hello world”. For this example, Quick Synthesis™ was used to produce a speech file, “hello.ves”. This file contains the label “VPhelloworld”, which allows our program to link to it. Creating a ‘Hello World’ Program Using the editor, we first create a document and save it: Go to "File", "New" then “Empty document” (CTRL-N) or press the button. An "untitled.vec" document will be created. Enter the following text: /* My first Voice Extreme program */ extern SPEECH VPhelloworld; // Label or address of speech data main () { Talk(0, &VPhelloworld); // Say “hello world” } Save it by pressing the button on the editor toolbar, using “hello” as a file name (the extension will be added automatically). The file “hello.vec” will be created. Creating the Project To generate the binary file, we need to create a project that contains the document, and then add any data files required for linking. Go to "Project" then "New". A document named "untitled.vep" will be created, and the project window will be opened. Add the document to the project by pressing the button. Add the speech file “hello.ves” by pressing the button; the file is located in the “samplesdataspeech” folder. Change the project description, if you like. Save the project. Go to “Project”, then “Save” and use “hello” as a file name (the extension will be added automatically). A file named “hello.vep” will be created. Building the Project At this point, we can compile our document and link it with the vocabulary file to produce a binary image in “hello.veb”. Go to “Project”, then “Build” or press the button. The "Build process" box will show each step performed by the builder, reporting any errors (shown in red). The blue progress bar provides an estimate of the remaining time to complete the build. At the end of the build process, the program makes a single beep and the "Build progress" box reports: "BUILD PROCESS OK”. If there are any errors, the text in the "Build progress" box turns red, and an error message will be reported. 28 P/N 80-0200-D © 2002 Sensory Inc.
  29. 29. Programmer’s Manual Voice Extreme™ Toolkit Downloading After a successful build, the binary image file is generated, in this case “hello.veb”. Now you are ready for the “Download” process. Go to “Project” then “Download” or press the button. The "Download process" box will show each step performed by the programmer, reporting any errors (shown in red). The blue progress bar provides an estimate of the remaining time. At the end of the download process the program makes a single beep, and the download progress box reports: "DOWNLOAD PROCESS OK". If there are any errors, the text in the build progress box turns red and an error message will be reported. The application is now stored in non-volatile memory in the module, allowing us to turn it off and on, saying “hello world” every time. Extending the ‘Hello World’ Program (add a blinking LED feature) 1. Open the “hello.vec” file or a new file and enter the following text: extern SPEECH VPhelloworld; // Start of the speech table #include <ve.veh> // Standard VE defs main() { ConfigureIO (1, 3, 3); // Configure the red LED (P1.3) to an output ConfigureIO (1, 5, 3); // Configure the green LED (P1.5) to an output ConfigureIO (1, 6, 3); // Configure the yellow LED (P1.6) to an output BEEP; while(FOREVER) //Infinite loop { if (ButtonAPressed) © 2002 Sensory Inc. P/N 80-0200-D 29
  30. 30. Voice Extreme™ Toolkit Programmer’s Manual Talk(0, &VPhelloworld); // Say "hello world" else if (ButtonBPressed) { // Red, Yellow and Green LEDs are active low DebugD8(1); // Debug speech “1” WritePort1(0xDF); // 0xDF = 11011111b, green LED DelayMilliSeconds(250); // on, all other LEDs off DebugD8(2); // Debug speech “2” WritePort1(0xBF); // 0xBF = 101111111b, yellow LED DelayMilliSeconds(250); // on, all other LEDs off DebugD8(3); // Debug speech “3” WritePort1(0xF7); // 0xF7 = 11110111b, red LED DelayMilliSeconds(250); // on, all other LEDs off DebugD8(4); // Debug speech “4” WritePort1(0xBF); // 0xBF = 101111111b, yellow LED DelayMilliSeconds(250); // on, all other LEDs off DebugD8(5); // Debug speech “5” WritePort1(0xDF); // 0xDF = 11011111b, green LED DelayMilliSeconds(250); // on, all other LEDs off DebugD8(6); // Debug speech “6” } } } 2. Build and download the program Build the project by pressing the button. After a successful build, download the “hello.veb” by pressing the button and pressing the “DOWNLOAD” button on the Voice Extreme development board. After you download the program, press button A or B on the development board to play “Hello World” speech or toggle the LED and play debug speech. Creating a Speaker Independent (SI) Sample Program. Now let’s replace the button press with a continuous listening SI word set. Note that currently Sensory does not offer tools to create custom SI vocabularies. Custom SI word sets can be ordered through Sensory at additional cost. Inquiries should be sent to: techsupport @sensoryinc.com. 1. Open the “hello.vec” file or a new file and enter the following text: extern SPEECH VPhelloworld; // Address of speech data extern WEIGHTS WT_call; // Weight file for word “call” const uint8 length = 0; // 0 for short duration const uint8 conf = 80; // Confidence threshold, 0 being the // worst score and 100 being the best score #include <ve.veh> // Standard VE definitions uint8 result; main() { while(FOREVER) //Infinite loop { JustGreenOn; // System "ready" result = CLPatGenW( 1, &WT_call); // Returns 0 if a valid // pattern created if ( result != 0) // If result not 0 execute next line continue; // otherwise go back to the beginning // of while loop JustRedOn; // System "busy" result = CheckDuration( length ); // Check the duration of the 30 P/N 80-0200-D © 2002 Sensory Inc.
  31. 31. Programmer’s Manual Voice Extreme™ Toolkit if ( result != 0 ) // pattern created continue; // Try again on duration error result = Recog( &WT_call); // Try recognize the pattern if ( result != 0 ) continue; // Try again on Recognition error result = GetRecogLevel1(); // Get the best recognition score if ( result < conf ) // Continue if the score is above continue; // the specified threshold JustYellowOn; // System "trigger" result = GetRecogMatch1(); // Get the best match if ( result == 0 ) Talk(0, &VPhelloworld); // Say "hello world" } } 2. Include the weight file to your project Open the project window by clicking the “Project” pull down menu and then selecting the “Project Window”, or just press F11. Add the SI weight file, “call.vew” by pressing the button. Sample weight files can be found in the “sensorysamplesdataweights” folder. Save the project by pressing the button. 3. Build and download the program Build the project by pressing the button. After a successful build, download the “hello.veb” by pressing the button and pressing the “DOWNLOAD” button on the Voice Extreme development board. After you download the program, say “call” to play the “hello world” speech. Creating a Speaker Dependent (SD) Sample Program. 1. Open the “hello.vec” file or a new file and enter the following text: extern SPEECH VPhelloworld; // start of the speech table extern SENTENCES SNsddemoa; TEMPLATE SD_Templates[1]; // allocate space in flash for 1 templates // Sentence table messages. Refer to sddemoa.vea for more information. #define SEN_SAY_WORD_1 1 // index of the first sentence #define SEN_SAY_A_WORD 33 // These index numbers are defined #define SEN_REPEAT 66 // in sddemoa.vea sentence table #define SEN_BEEP 71 #include <ve.veh> // Standard VE definitions const uint8 length = 0; // 0 = short; 1 = medium; 2 = long duration const uint16 conf = 130; // Confidence level threshold, 0 being the // best score and 255 being the worst score uint8 result; // Declare an 8-bit variable called result uint8 msg; uint8 tries = 3; uint8 word = 0; main() { //--------------------------------------------------------------------------- // Start the training process msg = SEN_SAY_WORD_1; // Setup the correct message to play © 2002 Sensory Inc. P/N 80-0200-D 31
  32. 32. Voice Extreme™ Toolkit Programmer’s Manual while (FOREVER) { SenTalk(msg, &SNsddemoa); // Prompt the user GreenOn; // Show the user it's ready to speak result = PatGen(STANDARD); // Create a template of the spoken word // The template will be saved in // the UNKNOWN buffer GreenOff; // Pattern generation complete if (result == 0) // Proceed if there is no PatGen error { if (word == 0) { PutTemplate(UNKNOWN, 0, SD_Templates); // Save the first // utterance into flash msg = SEN_REPEAT; // Setup the message to “Repeat” word = 1; } else { // load the first template into the KNOWN buffer GetTemplate(KNOWN, 0, SD_Templates); // compare & store the average of UNKNOWN & KNOWN template // in UNKNOWN buffer result = TrainSD(UNKNOWN, KNOWN, UNKNOWN); if (result == 0) // If the templates matches { PutTemplate(UNKNOWN, 0, SD_Templates); // save the average // template into flash break; // Exits the while loop } else // the templates are different { msg = SEN_SAY_WORD_1; // Start the training process again word = 0; } } } else msg = SEN_REPEAT; } // end of while loop // Training complete //--------------------------------------------------------------------------- SenTalk(SEN_BEEP, &SNsddemoa); // Beep twice to inform the SenTalk(SEN_BEEP, &SNsddemoa); // Training is complete while (FOREVER) { if (ButtonAPressed) { SenTalk(SEN_SAY_A_WORD, &SNsddemoa); YellowOn; // Ready to speak result = PatGen(STANDARD); // Create a template of the spoken word YellowOff; // PatGen done if (result == 0) { result = RecogSD(1, SD_Templates); // Try to recognize the template // found in UNKNOWN buffer if (result == 0) // If the word recognized, play Talk(0, &VPhelloworld); // the "Hello World" speech 32 P/N 80-0200-D © 2002 Sensory Inc.
  33. 33. Programmer’s Manual Voice Extreme™ Toolkit else { SenTalk(SEN_BEEP, &SNsddemoa); // otherwise, beep twice SenTalk(SEN_BEEP, &SNsddemoa); } } } } } 2. Add the speech file and sentence table to your project Open the project window by clicking the “Project” pull down menu and selecting the “Project Window”, or just press F11. Add the speech file, “sddemo.ves” by pressing the button, and add the sentence table, “sddemoa.veo by pressing the button. Sample speech files and sentence tables can be found in the sensorysamplesdataspeech folder. Save the project by pressing the button. 3. Build and download the program Build the project by pressing the button, or just press F9. After a successful build, download the “hello.veb” by pressing the button and pressing the “DOWNLOAD” button on the Voice Extreme development board. After you download the program, the unit will automatically restart and start the training process. Follow the prompts and train a word or short phrase. Once the word has been trained, press button A to start the recognition. After the prompt, say the trained word. If the word is recognized, the unit will say “Hello World”, otherwise, it will beep twice. © 2002 Sensory Inc. P/N 80-0200-D 33
  34. 34. Voice Extreme™ Toolkit Programmer’s Manual Voice Extreme™ Language: VE-C Introduction The Voice Extreme™ language, VE-C, is very similar to ANSI-standard C. It is assumed that the Voice Extreme™ programmer is familiar with C or similar higher-level language. This section will describe some of the features of the language, but it is also helpful to have a standard C reference manual, such as Kernighan and Ritchie’s The C Programming Language. VE-C/ANSI C comparison VE-C recognizes both C-style comments (/* … */) and C++-style comments (// …). VE-C has no limit on the length of identifiers, but the assembler limits symbols to 62 characters. Therefore, do not create any labels longer than 62 characters. The VE-C compiler generates labels that it uses when referencing string literals. It also generates a few segment names and a few labels for data structures that are used exclusively by VE. All of these names begin with the 3-character sequence “VE_”. A user can avoid conflicts with these names by not using any identifier that begins with this sequence. All VE-C variables and constants are static; i.e. space is statically allocated rather than using a stack. All constant objects are stored in flash memory. Variables declared with the flash (or FLASH) storage class are stored in flash memory. Variables declared with no storage class are stored in on-chip RAM. On-chip RAM storage for variables is limited to approximately 500 bytes. VE-C does not recognize the C storage class keywords static, auto, and register nor the type qualifier volatile. VE-C has seven basic types: int8, int16, int24, uint8, uint16, uint24, and void. sint8, sint16, sint24 are alternative names for int8, int16, int24. char and bool are functionally the same as int8; uchar is the same as uint8. VE-C recognizes the following built-in types that are not a part of C: TEMPLATE, WEIGHTS, SPEECH, SENTENCES, NOTES, TUNES. Type names can be written in all upper case or all lower case. The VE-C interpreter (that runs on the RSC) treats all operands as 24-bit values. If the operand is signed and shorter than 24 bits (i.e., its type is int8 or int16), the interpreter sign extends the value to 24 bits. Otherwise the interpreter zero-extends the value to 24 bits. The interpreter treats the extended 24-bit values as signed values. The means that VE-C can properly operate on only those unsigned values that are less than 0x800000. Arithmetic and logical operations on unsigned values that are greater than or equal to 0x800000 behave as expected. Comparison operations on these values treat them as signed (and therefore negative) values. VE-C does not recognize the type specifiers: short, long, unsigned, float, double. VE-C does not recognize long or floating constants or enumerated (enum) constants. VE-C recognizes only the following forms of multi-character constants inside string and character literals: n Line feed. This generates a new line, which is a carriage return followed by a line feed. t Horizontal tab. v Vertical tab. b Backspace. r Carriage return. f Form feed. a Audible alert (bell). Backslash. ” Double quote. ’ Single quote. ooo Unsigned 8-bit value represented by ooo, a sequence of 1 or more octal digits. If the value is larger than octal 377 (decimal 255), the constant’s value is its least significant byte. A special 34 P/N 80-0200-D © 2002 Sensory Inc.
  35. 35. Programmer’s Manual Voice Extreme™ Toolkit case of this is ‘0’, representing a zero byte. xhh Unsigned 8-bit value represented by hh, a sequence of 1 or more hex digits. If the value is larger than hex FF (decimal 255), the constant’s value is its least significant byte. . The period represents any single character that already hasn’t already been described in this list. The value of this character constant is the numeric value of the character that follows the backslash; e.g. ‘?’ is the same as ‘?’. VE-C does not recognize wide-char string literals. VE-C does not recognize the type pointer to function. VE-C does not allow assignment to structures or unions. VE-C does not allow bitfields within structures or unions. VE-C also does not allow a user to declare structures or unions that contain members that are any of the built-in data types or that have type “array of” any of the built-in data types. Integers may be added to pointers or subtracted from pointers. Before the addition or subtraction, the integer is multiplied by the size of the object to which the pointer points. VE does not allow subtraction of pointers. VE-C does not recognize the operators / and % (division and modulo). VE-C does not recognize the conditional operator (condition ? iftrue : iffalse). VE-C always evaluates both operands of logical AND (&&) and logical OR (||) operators, rather than stopping as soon as the value of the expression can be determined. The current version of the VE-C compiler restricts user-defined functions to those that do not use arguments. Because all variables, including local function variables, are allocated statically, care must be taken in writing recursive functions. VE-C allows only ANSI-standard function declarations and definitions, i.e. the types of the parameters must be specified inside the parentheses, not in a list that follows. VE-C does not allow variable length function parameter lists (i.e. ellipses …). The VE-C compiler does not provide access to the standard C runtime library. It does, however, provide access to about 100 built-in functions, described in the section “Voice Extreme Data Files”. The VE-C preprocessor recognizes the directives #include and #define but does not recognize the following directives: #if, #ifdef, #ifndef, #else, #elif, #endif, #undef, #error. If the filename for an #include is enclosed in angle brackets (#include <file>) the compiler looks for it in the folder defined by the VEInclude environment variable. If this variable is not defined, or if the filename is enclosed in double quotes, the compiler looks in the local folder. VE-C recognizes only the following two types of #pragma statements: #pragma VE_APP_TEXT “<string>” and #pragma VE_APP_VERSION <number> Note that multi-character constants (e.g. n) are not supported inside pragma strings. VE-C does not allow substitution of variables in user-defined macros (#define identifier(identifier-list) token- sequence) nor does it recognize and replace the trigraph sequences (in the form ??x, where x is one of the following characters: = / ‘ ( ) ! < > -). The following identifiers are not predefined in VE-C: __LINE__, __FILE__, __DATE__, __TIME__. __STDC__ © 2002 Sensory Inc. P/N 80-0200-D 35
  36. 36. Voice Extreme™ Toolkit Programmer’s Manual VE-C does not support inline assembly using the asm directive. VE-C does not recognize the following ANSI C keywords: asm, auto, catch, class, const_cast, default, delete, double, dynamic_cast, enum, explicit, float, friend, inline, int(1), long(1), mutable, namespace, new, operator, private, protected, public, register, reinterpret_cast, short, signed(1), static(2), static_cast, template(3), this, throw, try, typedef, typeid, typename, unsigned(1), using, virtual, volatile and wchar_t. Note: (1) VE recognizes the following standard data types: int8, int16, int24, sint8, sint16, sint24, uint8, uint16, uint24, char, uchar, bool and void. (2) VE-C declares all variables as static. (3) There is a VE data type called TEMPLATE, but it refers to speaker-dependant voice templates and has no relation to the ANSI C "template" reserved word. VE-C Data Types This section explains in details how Voice Extreme™ implements the data types. Note that the types can be spelled with all lower case or all upper case letters. An experienced C-programmer might want to just scan this section to understand the differences between ANSI-C and the Voice Extreme™ language (VE-C). Many programs use only the standard types and the built-in Sensory types, so the inexperienced programmer should not be intimidated by the more complex types!. Standard Data Types Unsigned integers. Unsigned integers are numbers that can only be 0 or positive. VE-C allows 3 types of integers, depending on whether the number is stored in 1,2 or 3 bytes. Since each byte is 8 bits, the types are uint8, uint16 and uint24. In multi-byte integers, the low order byte is stored first. Note that all VE-C addresses are stored as 24-bit unsigned integers. For example: UINT8 j; // declares a variable “j” that can store numbers // from 0 to 255 uint8 count = 128U; // Initializes a count variable to 128. The “U” tells // the parser that this is an “unsigned” number and // avoids a warning Signed integers. Signed integers are numbers that can be positive, negative or 0. As with unsigned integers, VE-C allows 3 types of signed integers: int8, int16 and int24. sint8, sint16 and sint24 are alternate names. For example: sint8 error; // declares a variable “error” that can store //numbers from -128 to 127 Char, Uchar. These data types are functionally the same as int8 and uint8, respectively, except that they normally only contain ASCII values. For example: uchar initial = ‘A’; // declares a variable “initial” which has //the value ‘A’ = 0x41 Bool. This data type is functionally the same as int8, except that it normally contains just the Boolean values 0 = FALSE or 1 = TRUE. For example, bool onoff; // declares a variable “onoff” which will either be TRUE or FALSE Voide. This data type is used to describe functions that either require no arguments or that return no values. In the “Hello World”, “main()” is equivalent to “void main(void)”. In function description, a function that does not return a value will be described as void. Built-in Sensory Data Types Template. A template is a 128-byte representation of a speech pattern. Typically a Voice Extreme™ program using the Speaker Dependent, Verification, or Wordspot technologies will declare storage for an array of 36 P/N 80-0200-D © 2002 Sensory Inc.
  37. 37. Programmer’s Manual Voice Extreme™ Toolkit TEMPLATEs. Voice Extreme™ automatically reserves template storage in flash memory, starting each template on a 128-byte boundary. For example: TEMPLATE passwords[4]; // declare storage for 4 passwords in flash Note that a TEMPLATE is the only built-in Sensory data type that actually requires the Voice Extreme™ program to reserve storage space. The following types are always declared as “extern” to the program; that is, the data is actually stored in a file linked with the program. “Voice Extreme™ Data Files” section contains more detailed descriptions of the data files and how they are generated. Weight. Weight sets are used with Speaker Independent Recognition. These data files typically contain a label starting with “WT”. Corresponding files in the weights folder contain the external definition of the label and a definition for the confidence level for the set. For example, the sample file “digits.veh” contains the lines: extern WEIGHTS WTdigits; #define CONFdigits 61 Speech. Speech vocabulary tables typically contain a label starting with “VP”. Corresponding sample files in the includespeech folder contain the external declaration of the label and definitions of the individual utterances in the set. For example, the sample file “hello.veh” contains the lines: extern SPEECH VPhelloworld; #define MSG_HELLO_WORLD 0 // First utterance in the set Sentences. Sentence tables typically contain a label starting with “SN”. The “sample shpeec folder” contains a source “.vea” file as well as an object “.veo” file. Corresponding files in the includespeech folder contain the external declaration of the label and definitions of the individual sentences in the set. For example, svdemoa.veh contains the lines: extern SENTENCES SNsvdemoa; #define SEN_PLEASE_SAY_FIRST 1 // First sentence in the set Tunes, Notes. A program using Music technology needs to link with both these types of data. Example: extern NOTES VEmusicdwc; extern TUNES VEmusiclis; Derived Data Types Arrays. An array is a group of same-typed variables stored consecutively in memory that are accessed with an integer 0-based index. For example: uint8 digits[10]; // The variable “digits” is an array of 10 // unsigned 8-bit integers digits[0] = 0; // Initialize the first element of the array VE-C allows multi-dimensional arrays, such as: UINT8 phoneNumbers[4][10]; // Storage for four 10-digit phone numbers Arrays can be initialized by specifying the contents for each member; e.g. char id[2] = {‘V’,‘E’}; // Initialize the two id bytes Strings. A string is an array of characters, terminated by a null (zero) byte. For example: uchar name[8] = “Sensory”; // Be sure to define enough storage for the © 2002 Sensory Inc. P/N 80-0200-D 37

×