![]() |
|
|||||||||||||||
|
||||||||||||||||
|
| How WebSphere Voice SDK can get your enterprise data to speak up for itself | ||||
You talkin' to me?
This article teaches you how to retrieve DB2 data using the sound of your voice. The project uses WebSphere Voice SDK 1.5, Visual Age for Java 4.0, and IBM DB2 UDB 7.2. We guide you step-by-step through a project we call "PeopleSearch," where you provide the application with a name and the application uses this name to query a database for data associated with the name. Introduction to the endeavor Fortunately for computer programmers, and for their paychecks, customers want more. Customers want to interact with their database using voice commands. They want to retrieve data housed in their relational database at the sound of their voice. Why do users want to use voice commands? Maybe they saw too many episodes of the Jetsons as children. Maybe they are too lazy to type. Or, maybe there is a legitimate reason behind this desire. Not only can vision-impaired users more easily interact with their data, but these applications could come in handy for mobile phones and other devices. Imagine being able to pull up a person's phone number by simply saying her name. We might even be able to spare the world from another person driving and dialing. Now that would be impressive. Guess what? We're here to impress. In this article, we show you how to retrieve voice-initiated enterprise data using IBM WebSphere Voice SDK V1.5, VisualAge for Java 4.0, and IBM DB2 Universal Database together. A few years ago this feat would have been impossible. Now, with the Voice Technologies infrastructure bundled with IBM VoiceServer SDK, we can reap the benefits of years of research behind IBM's patented voice recognition technologies. As we demonstrate in this article, you won't have to dig through thousands of lines of code to complete the assignment. The infrastructure needed to perform this seemingly complex goal is rather simple. But enough about what we are going to do. Let's do it. Prerequisites Our code was developed using IBM VisualAge 4.0 for Java. We will show you how to use this integrated development environment (IDE) to perform the project. We tap into the IDE's WebSphere Test Environment to emulate a WebSphere-like environment. Of course, in a real-world application, you wouldn't use a test environment; you'd use the real McCoy -- WebSphere Application Server. However, the WebSphere Test Environment is ideal for demonstrating our method and debugging the program. Installing IBM WebSphere Voice Server SDK Version 1.5.0 Setting up and populating the database Issue the following commands using the command-line processor to set up your environment:
Next, create a database table to accommodate your records (we've split the command onto several lines here, but you should type it all on one line):
Then, populate the database table with the following records:
Making VisualAge for Java a conversationalist You will need to edit the classpath of the Servlet Engine using the WebSphere Test Environment Control Center. Be sure to select the peopleSearch project you created in the "Select the projects to include the classpath" section. Also, provide the path to the IBM DB2 JDBC driver (db2java.zip) in the "Enter the class path" section. When you have done these two things, you should have something similar to what is shown in Figure 1. Figure 1. Setting the Servlet Engine Class Path In the project zip file, you will also notice two other files; a file named "welcome.vxml" and a file named "peoplesearch.jsp." Copy these two files to your WebSphere test environment directory. By default, the following would be the pertinent location:
Next, you need to start the Servlet Engine. You'll know that things are up and running when you see a message that states "***Servlet Engine is started***" in your console. Making the Test Environment and IBM Voice Server SDK cooperate Using the DOS prompt, go to the directory where the Voice Server SDK was installed. Under the install directory is a directory called "bin". We used the default installation settings, which means that our bin directory is located at C:\Program Files\VoiceServerSDK\bin\ . In this bin directory is a batch file that you will run. Issue the following DOS command:
When you do this for the first time, the Voice Server SDK invokes the Audio Setup Wizard (see Figure 2). Figure 2. The Audio Setup Wizard Take a few moments to set up your microphone and speakers. The questions asked are easy to answer, but your answers will depend on your particular audio setup. The setup wizard will guide you through the process (see Figure 3). Figure 3. The Audio Setup Wizard gets you up and running Be sure to adjust your microphone to get the optimal recording environment (see Figure 4). Figure 4. Adjust the headset as suggested by the wizard The wizard next guides you through a series of steps to determine your recording environment. These steps are straightforward and will take you only a few minutes to complete. When everything is set up using the wizard, you will be presented with a dialogue as follows:
At this point the system verifies the last name against the grammar file that is written inline for this application.
In a real-world application the grammar file would be created dynamically following the Java Speech Grammar Format (JSGF) and linked to the VoiceXML document. A complete discussion on grammar is beyond the scope of this article; but you can find more information on grammar in Resources. After the grammar validation, the system collects the input and executes the <filled> element in the people.vxml file if the user input is valid .
At this point the system forwards the request to a JavaServer Pages page, peoplesearch.jsp, using the VoiceXML tag <submit>. The last name of the person is sent to the JSP page in the Query String. In this JSP, we first state that our file is of the form "<vxml version="1.0">". This will let the VoiceSDK interpret the Voice tags in the JSP page. To grab the name that the user provides verbally from the request object, use the following syntax:
Note that our JSP is left oblivious to the form and fashion in which the information was provided. Using VXML, we did a one-to-one linking of the spoken last name to a last name we specified in the grammar. This last name was then concatenated to the query string from which we retrieve the parameter using the getParameter method. After grabbing the request parameter, we send the newly obtained information to the constructor of the com.ibm.peoplesearch.EmployeeInfo class, which is nothing more than a Database Access Object for the Employee table. The code for the constructor is shown below. Code for the com.ibm.peoplesearch.EmployeeInfo constructor
As you can see from the code, we first establish a connection to our DB2 database. Next, we create an SQL query using the last name inputted by the user. If a record is found that meets our criterion, then we populate our instantiated object's properties with the data. This data is then relayed to the VoiceSDK, which understand the tags and spells it out to the user using the computerized voice which sounds remarkably like those Speak-and-Spells that were the craze in the 80s. While the application presented here is rather rudimentary, you can expand on our little application, using it as a foundation for your enterprise solution. Conclusion
| ||||||||||||||||||||
| About IBM | Privacy | Terms of use | Contact |