Text to speech functionality in Test Automation

Step 1:

Download  java speech synthesis called FreeTTS.


If you plan on just creating applications with FreeTTS, the bin package will be sufficient

Download the zip folder go to lib install jsapi.exe. It will create a jar file namely jsapi.jar . Include all jar libraries to your project.

Step 2:  

Copy past the extricted file into the following folder

C:\Program Files\Java\jre1.8.0_151\lib\ext

Step 3:

Define the rule for JRE library

Note: Add “javafx/**”  in Rule Pattern as shown below 

Step 4: Write the following code in eclipse

package automation; // your package name

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

import java.awt.*;

import java.awt.event.*;

import java.util.concurrent.TimeUnit;

import javax.swing.*;

// importing for text to speech

import java.util.Locale;

import javax.speech.Central;

import javax.speech.synthesis.Synthesizer;

import javax.speech.synthesis.SynthesizerModeDesc;

public class TTS implements ActionListener {

// Skipping  adding the container, Apply layouts, create & add components etc

public void actionPerformed(ActionEvent event) {



// set property as Kevin Dictionary



// Register Engine



// Create a Synthesizer

Synthesizer synthesizer =

Central.createSynthesizer(new SynthesizerModeDesc(Locale.US));

//Allocate synthesizer


// Resume Synthesizer


// speaks the given text until queue is empty.

synthesizer.speakPlainText(“Completing the add new hire process for an employee so wait”, null);


// Deallocate the Synthesizer at the end of program or at termination of program



catch (Exception e)





// Main method

public static void main(String[] args) {

new TTS();


} // End of class


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: