If all you need is the end result of converting text to speech, you can try calling the command say "using ProcessBuilder, something like this:
String stuffYouWantToSay = "StackOverflow Rocks!";
Process p = null;
try {
ProcessBuilder pb = new ProcessBuilder("/usr/bin/say", stuffYouWantToSay);
p = pb.start();
} catch (Exception e) {
return;
}
This will not add it to the services menu, but you will still get the same effect.
Be sure to check the man page for "say" as you can change the voice.
source
share