Android Text To Speech Male Voice
Asked Answered
C

8

14

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?

Cacomistle answered 22/3, 2012 at 1:28 Comment(1)
refer my answer it works for me.i can set voice for male.https://mcmap.net/q/828238/-android-tts-male-voices/…Fillin
D
17

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"

Disruption answered 12/1, 2017 at 9:14 Comment(2)
its changing the voice name every time , i used for hindi male the value was Voice[Name: hi-in-x-cfn#male_3-local, locale: hi_IN, quality: 400, latency: 200] , now for hi-IN its showing Voice[Name: hi-in-x-hia-local, locale: hi_IN, quality: 400,] , Previously its working now its creating problemXenocryst
why does getVoices() return null? for no reason? I can't search for any traffic on itDecarlo
M
7

It is possible to change voice into male

here is my code,hope it will help you!

//onCreate  
T2S= new TextToSpeech(testApp.getInstance().getApplicationContext(), this, "com.google.android.tts");
    Set<String> a=new HashSet<>();
    a.add("male");//here you can give male if you want to select male voice.
    Voice v=new Voice("en-us-x-sfg#male_2-local",new Locale("en","US"),400,200,true,a);
    T2S.setVoice(v);
    T2S.setSpeechRate(0.8f);

implements TextToSpeech.OnInitListener on Activity.

@Override
public void onInit(int status) {
    if (status == TextToSpeech.SUCCESS) {
        Set<String> a=new HashSet<>();
        a.add("male");//here you can give male if you want to select male voice.
        //Voice v=new Voice("en-us-x-sfg#female_2-local",new Locale("en","US"),400,200,true,a);
        Voice v=new Voice("en-us-x-sfg#male_2-local",new Locale("en","US"),400,200,true,a);
        T2S.setVoice(v);
        T2S.setSpeechRate(0.8f);

       // int result = T2S.setLanguage(Locale.US);
        int result = T2S.setVoice(v);

        if (result == TextToSpeech.LANG_MISSING_DATA
                || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            Log.e("TTS", "This Language is not supported");
        } else {
           // btnSpeak.setEnabled(true);
            speakOut(mMessageVoice);
        }

    } else {
        Log.e("TTS", "Initilization Failed!");
    }
}

And add this function also:

private void speakOut(String message) {

    t1.speak(message, TextToSpeech.QUEUE_FLUSH, null);
}
Makassar answered 20/10, 2018 at 7:1 Comment(3)
but when we set locale like if (status == TextToSpeech.SUCCESS) { Set<String> a=new HashSet<>(); a.add("male"); Voice v=new Voice("hi-IN-x-sfg#male_2-local",new Locale("hi","IN"),400,200,true,a); tts.setVoice(v); int result = tts.setVoice(v); tts.setSpeechRate(0.8f); ------------->>>> it gives female voice why ? where i am missing ?Xenocryst
Its changing the values dynamically not fixed for male ---->e("hi-IN-x-sfg#male_2-local",new Locale("hi","IN"),400,200,true,a)Xenocryst
It's not working. It's still speaking in default female voice. Any way out?Taboret
A
3

You cannot make the Android TextToSpeech sounds like a male. If you change the TextToSpeech.setPitch() value to something low, like 0.1, it will sound very bad.

Your only option is to try another Text-to-Speech engine, or live with the female sounding voice.

Ailee answered 22/3, 2012 at 22:55 Comment(2)
Google has a new logo, but Android only has a female voice, incredible.Chester
Answer is not true anymore. For example en_UK now has 18 voices and almost half of them are male. Some locales still has only one language. Should be deleted or updated.Rundown
L
2

That depends on the underlying TTS engine. Some are configurable and have different voices (male, female, etc.), some only have one voice. In any case, you cannot control this from your app, the user has to change the TTS engine settings from the Settings app. You could only instruct them to install a particular engine, and setup your app to use it.

Leucocytosis answered 22/3, 2012 at 2:42 Comment(0)
P
2

Contrary to some previous answers, gender is not a parameter (or even a "feature") of a Voice object.

As you can see... as of 5/2021, there is no "isMale" boolean parameter.

There is a "features" Set<String> parameter, but what those strings actually contain is engine dependent and extremely poorly documented and/or implemented... and no engines describe gender using this parameter that I know of.

TextToSpeech.setVoice() is designed such that the Voice being set must be an exact match/instance of one of the Voice objects that was previously returned by TextToSpeech.getVoices() -- it is not a way to somehow create/request a new custom Voice or to attempt to mix and match parameters. (That's not to say some engines won't try to make a best approximation of the non-existent new voice you try to send to it).

Even if gender were implemented, Voice parameters are not designed to be independently settable.

Voice objects are a means by which an engine can describe its available voices using getVoices() -- they are not the voices themselves.

As far as I can tell, the Voice class' constructor is really not useful to anyone other than a speech engine developer.

All of this means that unless the authors of a specific engine have chosen to include "male" or "female" as a substring of the voice's name, there is no way for you to determine whether a voice sounds male or female other than listening to it first.

So, in order to control whether speech output "is" male/female, all the following would have to be true:

  1. you already know the unique voice name (String) you are looking for
  2. the engine that contains that voice is installed on the users device (not in your control)
  3. the installed version of that engine is recent enough to contain that voice (not in your control)
  4. the installed version of that engine is not too recent so as to no longer contain that voice (not in your control)
  5. the user has that particular voice installed (not in your control)
  6. if the voice is not installed, the user is connected to the internet (not in your control)

PS - Even if you think you've found a male voice, it could actually be a female that just sounds male to you. :)

PPS - You could use a cloud service instead to remove all the device unpredictability.

Porpoise answered 13/5, 2021 at 6:59 Comment(1)
You can adjust pitch/speed which can make a female voice "sound" lower/deeper (and to most would sound male).Ticonderoga
P
0

It is possible to change voice into male. Set in onCreate(): tts.setEngineByname("com.google.android.tts") and make the google tts service default in text to speech settings and instaling the male voice in google tts service.

Like this you can use any third party android tts services and check the device. Or ask to install.

Problem answered 3/7, 2015 at 12:53 Comment(0)
P
0

Either way you can set your android Text-to-Speech to google TTS service by :

  1. tts = new TextToSpeech(context, this, "com.google.android.tts"), or
  2. Install new male ( English ) voice and set it by default in android.

Hope it helps.

Particularity answered 18/6, 2017 at 9:57 Comment(0)
R
0

I found 3 Male voices in google tts

  1. en-in-x-ene-network
  2. en-in-x-end-network
  3. hi-in-x-hie-local

Use these in the following way:
textToSpeechEngine.voice = Voice("hi-in-x-hie-local", Locale("hi_IN"), 400, 200, false, HashMap<String>())

Recrudesce answered 21/9, 2022 at 12:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.