Here I post a code to select male or female voice using the Google speech engine.
Set<String> a=new HashSet<>(); a.add("female");//here you can give male if you want to select mail voice. Voice v=new Voice("en-us-x-sfg#female_2-local",new Locale("en","US"),400,200,true,a); myTTS.setVoice(v);
The name Voices is most taken care of here. like "en-us-x-sfg # female_2-local"
You can get all the votes using the following method, and you can load it into a file.
myTTS.getVoices() // you can get all voices of male female related information which we can set in Voice.whoever voice we want to listen.(male /female.)
source share