|
Demo Readme
|
Voice Bean Suite Version 2.0
These demos show how you can create an application that
will use the beans from the suite.
To see the wiring and run the application in VisualAge
for Java, Professional Edition, JDK 1.2 Technical Preview, follow the installation
instructions for the Bean Suite first. Next, import the FileManagement Bean Suite Version
3.0, which can be downloaded from the alphaWorks
web site. Then import the demo dat file (in the demo directory) into VisualAge
for Java 3.0. The dat file contains a demo package that you can add to any
project in your VisualAge workspace. DO NOT use VisualAge's "Check Class
Path..." option to compute the correct CLASSPATH setting. This will cause the demo to
throw an obscure exception. Finally, import the text1.txt file (in the demo
directory) as the resource into the same project.
How to Run This Demo
- First, make sure the Voice Bean Suite is properly installed,
as described in the documentation provided with this
package. Also, set the CLASSPATH for the filemanagement.jar included in the
FileManagement Bean Suite.
- Set the CLASSPATH to include Voice_Runtime.JAR
in the lib directory (for Windows OS, run setEnv.bat in command
prompt in the demo directory).
- Change to the demo directory, and type java
runDemoX (where X is equal to 1 or 2, depending on which Demo you want to
run) at the command prompt. This starts the DemoX.
Demo1
What the Demo Does
Suppose the text file looks like the following (this sample
file named demo1.txt can be found in the demo directory):
- IBM
- ViaVoice
- Lotus
By pressing the Recognizer button, the
application will start listening to the user. The recognized word is then shown in the Recognized
Word textfield. After that, type in the name of the file to the File Name
textfield (i.e. demo1.txt which is provided), and click on Find
Word button. If the word the application is trying to find is found in the file
being checked (the file typed into the File Name textfield), it will
result in "Found", and will say "Found." If the word is not in the
file, it will result in "Not Found."
The result of the Application is shown in Figure 1.

Figure 1 - The Voice Demo1
Where:
Recognize button - a button to start the
recognition.
Recognized Word TextField - a text field for the
recognized word from the user.
File Name TextField - a text field for the location
of the text file to search.
Find Word button - a button to start the search of
the string.
Result TextField - a text field for displaying the
result.
- Enter a text file full path name in the File Name
field (the default is demo1.txt).
- Click the Recognize button. Speak to the microphone
while the computer is listening. The recognized word is then displayed into the Recognized
Word field.
- Click the Find Word button. The file specified is
then checked to see if the recognized word is found. It will display the result in the Result
field.
- The computer will also talk the result to the user.
Wiring Instructions
Note: To simplify the wiring instructions, this demo
assumes only valid values have been provided for input file paths.
To build the application, you should do the following:
- Create a new class with the Frame superclass.
- Put on the frame:
- Button (set Recognize label);
- Button (set Find Word label);
- TextField for the recognized word (set the Recognized
Word label);
- TextField for the file name (set the File Name label,
set the text of TextField to be "demo1.txt");
- Label (set the Press the "Recognizer"
button label);
- Put on the design surface:
- The Speaker bean;
- The Listener bean;
- The TextFinder bean (from the File Management Suite);
Make the following connections:
- Connect the Recognize Button.actionPerformed event to
the Press the "Recognizer" button Label.setText method and set the value
parameter as "Getting ready to listen";
- Connect the Recognize Button.actionPerformed event to
the Listener.triggerAction method;
- Connect the Listener.recognizerReadyEvent event to the Press the
"Recognizer" button Label.setText method and set the value parameter as "Listening";
- Connect the Listener.resultText property to Recognized Word TextField.text property;
- Connect the Listener.triggerNextAction event to Press the
"Recognizer" Label.setText method and set the value parameter as "Done listening";
- Connect the Find Word Button.actionPerformed event to the Result TextField.setText method and
set the value parameter to "Not Found";
- Connect the Recognized Word TextField.text property to TextFinder.inputStringToSearch
property and choose textValueChanged as the Source Event;
- Connect the File Name TextField.text property to TextFinder.inputFileName
property and choose textValueChanged as the Source Event;
- Connect the Find Word Button.actionPerformed event to the TextFinder.triggerAction
method;
- Connect the
TextFinder.textFound event to Result TextField.setText method and
set the value parameter to be "Found";
- Connect the TextFinder.triggerNextAction event to Speaker.triggerAction method;
- Connect the Speaker.fetchArguments event to Speaker.inputText property and take the value parameter for this connection from Result
TextField.text
property.
Refer to Figure 2 for the wiring
diagram of this application.
Figure 2 - The Voice Demo1 wiring
diagram
Demo2
What the Demo Does
Suppose the text file looks like the following (this sample
file named demo2.txt can be found in the demo directory):
- Hello Randy, Jean-Paul and Koichi.
- How are you guys doing today?
- I am doing fine.
-
- Take care!
- Bye bye.
By pressing the Press to start button, the
application will start listening to the user for commands. It will read in demo2.JSGF
file for the grammar which recognizes two commands-"Open File" and "Read
File." If the user says "Open File," it'll open the file in the File
Name textfield (i.e. demo2.txt which is provided) and put the
text of the opened file into the textarea. Then, if the user says "Read File,"
it will start reading the text in the textarea.
The result of the Application is shown in Figure 3.

Figure 3 - The Voice Demo2
Where:
Press to start button - a button to start the the
application.
File Name TextField - a text field for the location
of the text file to read.
TextArea - a text area for displaying the opened file.
- Enter a text file full path name in the File Name
field (the default is demo2.txt).
- Click the Press to start button.
- Speak "Open File" to the microphone to issue an
"Open" command.
- Speak "Read File" to the microphone to issue a
"Read" command.
Wiring Instructions
Note: To simplify the wiring instructions, this demo
assumes only valid values have been provided for input file paths.
To build the application, you should do the following:
- Create a new class with the Frame superclass.
- Put on the frame:
- Button (set Press to start label);
- TextField for the file name (set the File Name label,
set the text of TextField to be "demo2.txt");
- Label (set the Press the button to start
label);
- TextArea for the opened file.
- Put on the design surface:
- The CommandListener bean (set inputFileName to demo2.JSGF);
- The CommandItem bean (set beanName to CommandItemOpen, set commandName to
"Open," set autoAction to false);
- The ReadFile bean (from the File Management Suite; set addLineSeparater to true);
- The CommandItem bean (set beanName to CommandItemRead, set commandName to
"Read," set autoAction to false);
- The Speaker bean;
Make the following connections:
- Connect the File Name TextField.text property to ReadFile.inputFileName property
and choose textValueChanged as the Source Event;
- Connect the TextArea.text property to Speaker.inputText property and choose textValueChanged as the Source Event;
- Connect the Press to start Button.actionPerformed event to
the CommandListener.triggerAction method;
- Connect the CommandListener.recognizerReadyEvent event to the Press the
button to start Label.setText method and set the value parameter as "Please say a
command";
- Connect the CommandListener.resultCommand property to CommandItemOpen.inputCommand property;
- Connect the CommandListener.resultCommand property to CommandItemRead.inputCommand property;
- Connect the CommandListener.triggerNextAction event to CommandItemOpen.triggerAction method;
- Connect the CommandListener.triggerNextAction event to CommandItemRead.triggerAction method;
- Connect the CommandListener.commandNotRecognized event to CommandListener.triggerAction method;
- Connect the CommandItemOpen.commandAccepted event to TextArea.setText method and set the
value parameter as "";
- Connect the CommandItemOpen.commandAccepted event to Press the button to start Label.setText method and set
the value parameter to "Opening a file";
- Connect the CommandItemRead.commandAccepted event to Press the button to start Label.setText method and set
the value parameter to "Reading a file";
- Connect the CommandItemOpen.commandAccepted event to ReadFile.triggerAction method;
- Connect the CommandItemRead.commandAccepted event to Speaker.triggerAction method;
- Connect the ReadFile.onNextLine event to TextArea.append method and set the value parameter as ReadFile.currentStringResult property;
- Connect the ReadFile.triggerNextAction event to CommandListener.triggerAction method;
- Connect the Speaker.triggerNextAction event to CommandListener.triggerAction method;
Refer to Figure 4 for the wiring
diagram of this application.

Figure 4 - The Voice Demo2 wiring
diagram