beans

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

  1. 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.
  2. 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).
  3. 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.

Demo1

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.

  1. Enter a text file full path name in the File Name field (the default is demo1.txt).
  2. Click the Recognize button. Speak to the microphone while the computer is listening. The recognized word is then displayed into the Recognized Word field.
  3. 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.
  4. 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:

  1. Create a new class with the Frame superclass.
  2. Put on the frame:
    1. Button (set Recognize label);
    2. Button (set Find Word label);
    3. TextField for the recognized word (set the Recognized Word label);
    4. TextField for the file name (set the File Name label, set the text of TextField to be "demo1.txt");
    5. Label (set the Press the "Recognizer" button label);
  3. Put on the design surface:
    1. The Speaker bean;
    2. The Listener bean;
    3. The TextFinder bean (from the File Management Suite);

Make the following connections:

  1. 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";
  2. Connect the Recognize Button.actionPerformed event to the Listener.triggerAction method;
  3. Connect the Listener.recognizerReadyEvent event to the Press the "Recognizer" button Label.setText method and set the value parameter as "Listening";
  4. Connect the Listener.resultText property to Recognized Word TextField.text property;
  5. Connect the Listener.triggerNextAction event to Press the "Recognizer" Label.setText method and set the value parameter as "Done listening";
  6. Connect the Find Word Button.actionPerformed event to the Result TextField.setText method and set the value parameter to "Not Found";
  7. Connect the Recognized Word TextField.text property to TextFinder.inputStringToSearch property and choose textValueChanged as the Source Event;
  8. Connect the File Name TextField.text property to TextFinder.inputFileName property and choose textValueChanged as the Source Event;
  9. Connect the Find Word Button.actionPerformed event to the TextFinder.triggerAction method;
  10. Connect the TextFinder.textFound event to Result TextField.setText method and set the value parameter to be "Found";
  11. Connect the TextFinder.triggerNextAction event to Speaker.triggerAction method;
  12. 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.

Wiring diagram 1

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.

Demo2

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.

  1. Enter a text file full path name in the File Name field (the default is demo2.txt).
  2. Click the Press to start button.
  3. Speak "Open File" to the microphone to issue an "Open" command.
  4. 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:

  1. Create a new class with the Frame superclass.
  2. Put on the frame:
    1. Button (set Press to start label);
    2. TextField for the file name (set the File Name label, set the text of TextField to be "demo2.txt");
    3. Label (set the Press the button to start label);
    4. TextArea for the opened file.
  3. Put on the design surface:
    1. The CommandListener bean (set inputFileName to demo2.JSGF);
    2. The CommandItem bean (set  beanName to CommandItemOpen, set commandName to "Open," set autoAction to false);
    3. The ReadFile bean (from the File Management Suite; set addLineSeparater to true);
    4. The CommandItem bean (set  beanName to CommandItemRead, set commandName to "Read," set autoAction to false);
    5. The Speaker bean;

Make the following connections:

  1. Connect the File Name TextField.text property to ReadFile.inputFileName property and choose textValueChanged as the Source Event;
  2. Connect the TextArea.text property to Speaker.inputText property and choose textValueChanged as the Source Event;
  3. Connect the Press to start Button.actionPerformed event to the CommandListener.triggerAction method;
  4. 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";
  5. Connect the CommandListener.resultCommand property to CommandItemOpen.inputCommand property;
  6. Connect the CommandListener.resultCommand property to CommandItemRead.inputCommand property;
  7. Connect the CommandListener.triggerNextAction event to CommandItemOpen.triggerAction method;
  8. Connect the CommandListener.triggerNextAction event to CommandItemRead.triggerAction method;
  9. Connect the CommandListener.commandNotRecognized event to CommandListener.triggerAction method;
  10. Connect the CommandItemOpen.commandAccepted event to TextArea.setText method and set the value parameter as "";
  11. Connect the CommandItemOpen.commandAccepted event to Press the button to start Label.setText method and set the value parameter to "Opening a file";
  12. Connect the CommandItemRead.commandAccepted event to Press the button to start Label.setText method and set the value parameter to "Reading a file";
  13. Connect the CommandItemOpen.commandAccepted event to ReadFile.triggerAction method;
  14. Connect the CommandItemRead.commandAccepted event to Speaker.triggerAction method;
  15. Connect the ReadFile.onNextLine event to TextArea.append method and set the value parameter as ReadFile.currentStringResult property;
  16. Connect the ReadFile.triggerNextAction event to CommandListener.triggerAction method;
  17. Connect the Speaker.triggerNextAction event to CommandListener.triggerAction method;

Refer to Figure 4 for the wiring diagram of this application.

Wiring diagram 2

Figure 4 - The Voice Demo2 wiring diagram