Android TTS male voices
Asked Answered
I

5

2

Is it possible to install and configure some male voices on android.speech.tts.Voice? I have read some news that Android had made some available recently, but I can't find or configure any. All the ones that I try with command tts.setLanguage(Locale.ITALY); are female.

Insipience answered 17/4, 2016 at 19:33 Comment(1)
refer my answer it works for me.i can set voice for male.https://mcmap.net/q/828238/-android-tts-male-voices/…Leeanneleeboard
E
6

No, not at present. An enhancement request is needed so that the gender can be included in the Voice Feature Set, such that:

Voice[Name: en-AU-afi-network, locale: en_AU, quality: 500, latency: 400, requiresNetwork: true, features: [networkTimeoutMs, networkRetriesCount, male]]

I have sent emails to Text to Speech providers about including this - as waiting for an enhancement from Google is probably years away.

All you can do in the mean time, is hard-code the name of the engine with a reference to the gender. It's time consuming and there's no guarantee that they won't change the name.... Needs must for me.

Elbertine answered 20/4, 2016 at 13:33 Comment(3)
do you know what "afi" mean in the voice name?Effector
@Elbertine I am creating an application which uses text to speech and I want to use different voice instead of it's default female voice which sounds like robotic. I did R&D on this but couldn't find any way to integrate male voice. I have got all voices from tts.getVoices() and I have hard coded the name of the engine but It doesn't support in some devicesHemispheroid
when i use Set<String> a=new HashSet<>(); a.add("male"); //Voice v=new Voice("en-us-x-sfg#female_2-local",new Locale("en","US"),400,200,true,a); Voice v=new Voice("hi-IN-x-sfg#male_2-local",new Locale("hi","IN"),400,200,true,a); tts.setVoice(v); if (status == TextToSpeech.SUCCESS) { int result = tts.setVoice(v); ------------------> it always gives female voice for hi-IN locale , please help mePushbike
A
7

To enhance @brandall 's answer, It is possible to use male/female voice and change it from App UI dynamically. Define TTS like this (add 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"

Alkylation answered 12/1, 2017 at 9:11 Comment(3)
I have hard coded the name of the engine as you define above but It doesn't support in some devices and speak in default voice. What could be the solution ?Hemispheroid
i want male voice for locale hi,---- >it always gives female voice for hi-IN locale – I used your code to fetch tts.getVoices() and previously it was giving the proper value like => "hi-in-x-cfn#male_3-local" , But now it changes the tts.getVoices() changes the value => Voice[Name: hi-in-x-hia-local, locale: hi_IN, quality: 400, latency: 200,requiresNetwork: false, features: [networkTimeoutMs, networkRetriesCount]] , Please guide me where i am missing ?Pushbike
@GyanSwaroopAwasthi Use "hi-in-x-hie-local" in place of _voiceName here. It will give you a male voice.Gizzard
E
6

No, not at present. An enhancement request is needed so that the gender can be included in the Voice Feature Set, such that:

Voice[Name: en-AU-afi-network, locale: en_AU, quality: 500, latency: 400, requiresNetwork: true, features: [networkTimeoutMs, networkRetriesCount, male]]

I have sent emails to Text to Speech providers about including this - as waiting for an enhancement from Google is probably years away.

All you can do in the mean time, is hard-code the name of the engine with a reference to the gender. It's time consuming and there's no guarantee that they won't change the name.... Needs must for me.

Elbertine answered 20/4, 2016 at 13:33 Comment(3)
do you know what "afi" mean in the voice name?Effector
@Elbertine I am creating an application which uses text to speech and I want to use different voice instead of it's default female voice which sounds like robotic. I did R&D on this but couldn't find any way to integrate male voice. I have got all voices from tts.getVoices() and I have hard coded the name of the engine but It doesn't support in some devicesHemispheroid
when i use Set<String> a=new HashSet<>(); a.add("male"); //Voice v=new Voice("en-us-x-sfg#female_2-local",new Locale("en","US"),400,200,true,a); Voice v=new Voice("hi-IN-x-sfg#male_2-local",new Locale("hi","IN"),400,200,true,a); tts.setVoice(v); if (status == TextToSpeech.SUCCESS) { int result = tts.setVoice(v); ------------------> it always gives female voice for hi-IN locale , please help mePushbike
K
2
// use this code after onInit success assuming you have initilaised text to speech as tts

Set<Voice> voices = tts.getVoices();
for (Voice tmpVoice : tts.getVoices()) {
    if (tmpVoice.getName().contains("#male") && tmpVoice.getName().contains("en-us")) {
        voice = tmpVoice;
        break;
    }
    else {
        voice = null;
    }
}
if (voice != null) {
    tts.setVoice(voice);
}

use this code on after on_init gets successful, do a version check because getVoices() got added on API level 21

Kranz answered 4/9, 2018 at 0:46 Comment(1)
In the above solution if (tmpVoice.getName().contains("#male") && tmpVoice.getName().contains("en-us")) Never gives true result because tts.getVoice() doesn't contains such things like "male" keywords , Two Days before i get the result for male and female voice but now same code is not working for male , every time female voice and tts.getVoices() gives Voice[Name: hi-in-x-hia-local, locale: hi_IN, quality: 400, latency: 200,requiresNetwork: false, features: [networkTimeoutMs, networkRetriesCount]] where i don't get the male voice. Please guide me why it is happening.Pushbike
L
0

Here I am posting code for select male or female voice using 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);

Here most take care about Voices name. like "en-us-x-sfg#female_2-local"

You can get all voices by using following method and you can download in 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.)
Leeanneleeboard answered 23/3, 2018 at 7:12 Comment(4)
what are the default voices support by devices for locale es_ES including male or female? or if device not support, it will install first then use? what could be the solution ?Hemispheroid
it depends on speech engine have voices.otherwise need to install speech engine and particular voices provided by speech engine.Leeanneleeboard
I have a requirement to speech text in human voice or the voice not to be robotic. Is there any way to achieve ? Is there any default engine for device?Hemispheroid
i want male voice for locale hi,---- > when i use Set<String> a=new HashSet<>(); a.add("male"); //Voice v=new Voice("en-us-x-sfg#female_2-local",new Locale("en","US"),400,200,true,a); Voice v=new Voice("hi-IN-x-sfg#male_2-local",new Locale("hi","IN"),400,200,true,a); tts.setVoice(v); if (status == TextToSpeech.SUCCESS) { int result = tts.setVoice(v); ------------------> it always gives female voice for hi-IN locale , please help me –Pushbike
G
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>())

Gizzard answered 21/9, 2022 at 11:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.