Android Text To Speech Male Voice

user1284791 picture user1284791 · Mar 22, 2012 · Viewed 24.3k times · Source

I have a working text to speech but I was wondering instead of a female voice when the app calls it to be played it will do a male voice instead?

Answer

Saad Mahmud picture Saad Mahmud · Jan 12, 2017

It is now possible to use male/female voice and change it from App UI dynamically. Define TTS like this (add google tts engine in constructor):

tts = new TextToSpeech(context, this, "com.google.android.tts");

contex = activity/app

this= TextToSpeech.OnInitListener

From tts.getVoices() list, chose your desired voice by it's name like this:

for (Voice tmpVoice : tts.getVoices()) {
        if (tmpVoice.getName().equals(_voiceName)) {
            return tmpVoice;
            break;
        }
}

N.B: U need to set _voiceName by getting hard coded voice_name from tts.getVoices(). e.g: for English male it would be: "en-us-x-sfg#male_1-local"