Link

Use for Text to Speech

JPedal has the ability to speak text that has been highlighted. You can use any speech library you wish and have it work with the existing JPedal functionality. This is done by creating your own Speech implementation.

Creating a speech class.

In order to create a speech engine, you need to implement the interface org.jpedal.io.Speech. This interface has the following four methods:

public void setVoice(String voiceName);

This method allows JPedal to set which voice should be used in the text to speech. This method should allow for incorrect names being passed in and use a default if the name is not in your voice list.

public boolean speechAvailible();

This method determines if the class is currently capable of speaking any text. This can be used to ensure any required jars are present.

public String[] listVoices();

This method returns a list of voices that can be used to speak selected text. Any attempts to change voice should check this method returned value to ensure it is present. This method is also used in the preferences window to display the possible voices to allow the user a choice.

public void speakText(final String text);

This method performs the actual speaking of the text. The text passed in is the extracted text highlighted on the page.

Adding the speech implementation

To use your speech implementation in the JPedal example viewer you will need to add it in the following way. When adding the functionality you should add the Speech class after the Viewer is created as shown below.

Speech mySpeechImp;
//Initialize your Speech implementation here

Viewer viewer = new Viewer();
viewer.setupViewer();
PdfDecoderInt pdfDecoder = viewer.getPdfDecoder();
pdfDecoder.addExternalHandler(mySpeechImp, Options.SpeechEngine);


After this, so long as your speech implementation speechAvailible() method is returning true, you will be able to use the functionality.

Accessibility Options for Text to Speech

This tutorial explains how you can use various options to make the viewer more accessible to those with more specific needs, you can find it here.

Still need help? Send us your questions.