Java InstantCode. Developing Applications using Java Speech API
To test the Speech-Enabled Calendar application:
-
Download the free implementation of Speech Converter API from the following URL:
http://freetts. sourceforge .net/docs/index.php
-
Set the path of the bin directory of J2SDK by executing the following command at the command prompt:
set path=%path%;D:\j2sdk1.4.0_02\bin;
-
Set the classpath of the lib directory of J2SDK and Speech Converter API by executing the following command at the command prompt:
set classpath = %classpath%;d:\j2sdk1.4.0_02\lib;C:\j2sdk1.4.0_02\lib;c:\freetts-bin-1_2_beta\lib\ freetts.jar;c:\freetts-bin-1_2_beta\lib\cmulex.jar;c:\freetts-bin-1_2_beta\lib\jsapi.jar;
-
Copy the SpeechCalendar.java, SpeakText.java, and SelectFormat.java files to a folder on your computer. Use the cd command at the command prompt to move to the folder in which you have copied the Java files. Compile the files by using the following javac command:
javac *.java
-
To run the Speech-Enabled Calendar application, type the following command at the command prompt:
java SpeechCalendar
-
The user interface of the Speech-Enabled Calendar application appears with the Date tab selected, as shown in Figure 2-2. Click the Select Date Format button to select a date format and click OK. The selected date format appears with the Enter Date option, as shown in Figure 2-4:
Figure 2-4: The Selected Date Format -
Click the Speak button to convert the specified date to speech. The specified date is converted to speech, which is audible with the help of speakers .
-
Click the Day tab to view the Day tab interface, as shown in Figure 2-5:
Figure 2-5: The Day Tab -
Click the Time tab to specify a time value, as shown in Figure 2-6:
Figure 2-6: The Time Tab
Категории