Last reviewed: 3/23/2024 10:22:37 AM
Java Applications
Develop Java applications that speak and listen using your favorite Java development tools. This includes development environments such as Eclipse, IntelliJ, JDeveloper, and NetBeans.
The following sections describe the steps for integrating SpeechKit with Java applications.
JRE Configuration
SpeechKit includes Java libraries for JDK 1.8, 11, 17, and 21 to support most applications' target runtime environments. If you need a specific target runtime, then contact Chant Product Support.
To access the SpeechKit Java classes within your application, add the class libraries to your JDK environment:
- copy the JSpeechKit.DLL file to your Java JDK bin directory;
- copy the applicable 32-bit speech API DLL file(s) to your Java JDK bin directory;
- copy the speechkit.jar and chant.shared.jar libraries to your Java JDK lib; and
- append a path reference for your Java JDK lib\speechkit.jar and lib\chant.shared.jar paths as a classpath property in your system settings.
- copy the JSpeechKitX64.DLL file to your Java JDK bin directory;
- copy the applicable 64-bit speech API DLL file(s) to your Java JDK bin directory;
- copy the speechkit.jar and chant.shared.jar class libraries to your Java JDK lib; and
- append a path reference for your Java JDK lib\speechkit.jar and lib\chant.shared.jar paths as a classpath property in your system settings.
To access the SpeechKit Java classes within your application, add references to the Chant shared and SpeechKit class libraries in your code:
import com.speechkit.*;
import net.chant.shared.*;
Object Instantiation
Declare a global variable for the SpeechKit class, instantiate an instance, set the credentials, and set the event handler.
public class Frame1 extends JFrame implements com.SpeechKit.JChantSpeechKitEvents
{
private JSpeechKit _SpeechKit = null;
private JChantRecognizer _Recognizer = null;
private JChantSynthesizer _Synthesizer = null;
private void jInit() throws Exception
{
// Create SpeechKit object
_SpeechKit = new JSpeechKit();
// Set credentials
_SpeechKit.setCredentials("Credentials");
_Recognizer = _SpeechKit.createChantRecognizer();
if (_Recognizer != null)
{
// Set the callback object
_Recognizer.setChantSpeechKitEvents(this);
// Register for callbacks
_Recognizer.registerCallback(ChantSpeechKitCallback.CCSRRecognitionCommand);
}
_Synthesizer = _SpeechKit.createChantSynthesizer();
if (_Synthesizer != null)
{
// Set the callback object
_Synthesizer.setChantSpeechKitEvents(this);
// Register for callbacks
_Synthesizer.registerCallback(ChantSpeechKitCallback.CCTTSWordPosition);
}
}
}
SpeechKit Java applications require the speechkit.jar and chant.shared.jar in the target system Java JRE lib directory and/or ensure the classpath includes the path where the speechkit.jar and chant.shared.jar libraries are placed on your target system. The SpeechKit library (JSpeechKit.dll or JSpeechKitX64.dll) and the applicable SpeechKit Speech API library must be in the target system Java JRE bin directory.
Speech API | SpeechKit Speech API class | SpeechKit Speech API library |
---|---|---|
Acapela TTS | JAcaTTSSynthesizer | CSpeechKit.AcaTTS.dll or CSpeechKitX64.AcaTTS.dll |
Cepstral Swift | JSwiftSynthesizer | CSpeechKit.Swift.dll or CSpeechKitX64.Swift.dll |
CereProc CereVoice | JCereVoiceSynthesizer | CSpeechKit.CereVoice.dll or CSpeechKitX64.CereVoice.dll |
Microsoft Azure Speech | JMCSRecognizer or JMCSSynthesizer | CSpeechKit.MCS.dll or CSpeechKitX64.MCS.dll |
Microsoft SAPI 5 | JSAPI5Recognizer or JSAPI5Synthesizer | CSpeechKit.SAPI5.dll or CSpeechKitX64.SAPI5.dll |
Microsoft Speech Platform | JMSPRecognizer or JMSPSynthesizer | CSpeechKit.MSP.dll or CSpeechKitX64.MSP.dll |
Microsoft WindowsMedia (WinRT C++) | JChantRecognizer or JChantSynthesizer | CSpeechKit.WinRT.dll or CSpeechKitX64.WinRT.dll |
Microsoft WindowsMedia (WinRT C++) | JWindowsMediaRecognizer or JWindowsMediaSynthesizer | CSpeechKit.WinRT.dll or CSpeechKitX64.WinRT.dll |
Nuance Dragon NaturallySpeaking | JDgnRecognizer | CSpeechKit.Dgn.dll or CSpeechKitX64.Dgn.dll |
Event Callbacks
Event callbacks are the mechanism in which the class object sends information back to the application such as compilation is complete or there was an error.
public void recognitionCommand(Object sender, RecognitionCommandEventArgs args)
{
if ((args != null) && (args.getPhrase() != null))
{
...
}
}
public void wordPosition(Object sender, WordPositionEventArgs args)
{
if (args != null)
{
int startPosition = args.getPosition();
int wordLength = args.getLength();
...
}
}
Development and Deployment Checklist
When developing and deploying Java applications, ensure you have a valid license, bundle the correct Chant class libraries, and configure your installation properly on the target system. Review the following checklist before developing and deploying your applications:
- Develop and deploy Java applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
- Copy speechkit.jar and chant.shared.jar to the target system Java JRE lib directory and/or ensure the classpath includes the path where the speechkit.jar and chant.shared.jar libraries are placed on your target system.
- Copy JSpeechKit.dll to the target system Java JRE bin directory.
- Copy applicable 32-bit SpeechKit Speech API DLL(s) to the target system Java JRE bin directory.
- Copy applicable 32-bit Microsoft Cognitive Services client DLLs to the target system Java JRE bin directory when using Azure Speech.
- Develop and deploy Java applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
- Copy speechkit.jar and chant.shared.jar to the target system Java JRE lib directory and/or ensure the classpath includes the path where the speechkit.jar and chant.shared.jar libraries are placed on your target system.
- Copy JSpeechKitX64.dll to the target system.
- Copy applicable 64-bit SpeechKit Speech API DLL(s) to the target system Java JRE bin directory.
- Copy applicable 64-bit Microsoft Cognitive Services client DLLs to the target system Java JRE bin directory when using Azure Speech.
Sample Projects
Java sample projects are installed at the following location:
- Documents\Chant\SpeechKit 13\Java.