Java Speech API: The Java Speech API allows Java applications to incorporate speech technology into their user interfaces. It defines a cross-platform API to support command and control recognizers, dictation systems and speech synthesizers.
Java Speech supports speech synthesis which means the process of generating spoken the language by machine on the basis of written input.
It is important to keep in mind that Java Speech is only a specification i.e. no implementation is included. Thus third-parties provide the implementations. The javax.speech package defines the common functionality of recognizers, synthesizers, and other speech engines. The package javax.speech.synthesis extends this basic functionality for synthesizers.
We will understand that what is required for java API to convert text to speech
- Engine: The Engine interface is available inside the speech package.”Speech engine” is the generic term for a system designed to deal with either speech input or speech output.
- Central: Central provides the ability to locate, select and create speech recognizers and speech synthesizers.
- SynthesizerModeDesc: SynthesizerModeDesc extends the EngineModeDesc with the properties that are specific to speech synthesizers.
- Synthesizer: The Synthesizer interface provides primary access to speech synthesis capabilities.SynthesizerModeDesc adds two properties: List of voices provided by the synthesizer Voice to be loaded when the synthesizer is started.
Below is an open-source implementation of Java Speech Synthesis called FreeTTS in the form of steps:
- Download the FreeTTS in the form of zip folder from here
- Extract the zip file and go to
- Open the jsapi.exe file and install it.
- This will create a jar file by the name jsapi.jar. This is the JAR library that contains the FreeTTS library to be included in the project.
- Create a new Java project in your IDE.
- Include this jsapi.jar file into your project.
- Now copy the below code into your project
- Execute the project to get the below expected output.
Below is the code for the above project:
Related article: Convert Text to Speech in Python
This article is contributed by Akash Sharan. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Speech Recognition in Python using Google Speech API
- Convert Text to Speech in Python using win32com.client
- How to Convert Speech to Text in Android?
- How to Convert Text to Speech in Android?
- Java | Converting an Image into Grayscale using cvtColor()
- Different ways of Reading a text file in Java
- Counting number of lines, words, characters and paragraphs in a text file using Java
- Java program to delete certain text from a file
- Java program to delete duplicate lines in text file
- Java Swing | Create a simple text editor
- How to Setup Sublime Text 3 for Java in Windows?
- Text Analysis in Python 3
- Difference Between Data Mining and Text Mining
- How to change the Text Color of a Substring in android using SpannableString class?
- Methods for Text Clipping in Computer Graphics
- Sending a Text Message Over the Phone Using SmsManager in Android
- Java.util.BitSet class methods in Java with Examples | Set 2
- Java.Lang.Float class in Java
- Java.io.BufferedInputStream class in Java
- Java.io.ObjectInputStream Class in Java | Set 1
Improved By : RishabhPrabhu