text to speech - Custom voice for TextToSpeech Android -
is there possibility set custom voice tts baby girl voice?
i have tried getvoices() following,
if (build.version.sdk_int >= 21) { set<locale> localeset = tts.getavailablelanguages(); (locale locale : localeset) { log.v(tag, locale.getdisplayname() + " - " + locale.getdisplaylanguage() + " - " + locale.getcountry()); if (locale.getdisplaylanguage().equals("tamil")) { result = tts.setlanguage(locale); if (result == texttospeech.lang_missing_data || result == texttospeech.lang_not_supported) { log.e("tts", "this language not supported"); } else { tts.setspeechrate(0.05f); //tts.setpitch(5.0f); fabspeak.setenabled(true); speakout(); } } } set<voice> voices = tts.getvoices(); (voice voice : voices) { log.v(tag, voice.getname()); if (voice.getname().equals("hi-in-x-cfn#female_2-local")) { tts.setvoice(voice); } } }
but voice replaced language, code doesn't read tamil anymore. if comment setvoice()
read tamil default male voice.
i want given text read female voice. possible?
this scenario occurs because default every voice has locale value overrides locale value set on function. think can override creating new voice instance features same set desired 1 overriding locale attribute in loop such:
for (voice voice: voices) { log.v(tag, voice.getname()); if (voice.getname().equals("hi-in-x-cfn#female_2-local")) { tts.setvoice(new voice(voice.getname(), locale, // locale goes here voice.getquality(), voice.getlatency(), voice.isnetworkconnectionrequired(), voice.getfeatures())); } }
wiki
Comments
Post a Comment