Theo D.
Theo D.

Reputation: 153

Custom Python gTTS voice

I have been using the gTTS module for python 3.4 to make mp3 files of spoken text. It has been working, but all of the speech is in a certain adult female voice. Is there a way to customize the voice that gTTS reads the text in?

Upvotes: 15

Views: 78037

Answers (7)

Deven Kumbhani
Deven Kumbhani

Reputation: 41

yes, you can do that if you want to change the language or give another accent. gTTS('hello', lang='en', tld='com.au'). where 'tld' parameter is used for accent. for more accent check this .

Upvotes: 4

Chris J
Chris J

Reputation: 21

Yes, you can customize the text in a few languages and accents. You can find the full documentation here:

gTTS docs

You can try the different languages and accents this way:

tts_obj = gTTS(text=tts, tld=tlds["South Africa"], lang=lang, slow=False)

Upvotes: 2

rocketFox
rocketFox

Reputation: 75

You can easily change the output-language by passing an second parameter when requesting a tts. So go like:

tts = gTTS("Say something", lang = 'XX') #replace XX with your language code

On the python doc website for Google Text-to-Speech you can find a table with some of the language codes from a few countrys.

Upvotes: -1

thisisnotshort
thisisnotshort

Reputation: 352

If you call "gtts-cli --all" from a command prompt, you can see that gTTS actually supports a lot of voices. However, you can only change the accents, and not the gender.

Upvotes: 2

Wudfulstan
Wudfulstan

Reputation: 147

You can always use pyttsx3, It defaults to male, but you can change it to female voice as well and there are a lot more parameters you can change like speed and volume. I thing gtts voice quality is slightly better still though. Here is some documentation to get you started if you want to use it: https://www.geeksforgeeks.org/text-to-speech-changing-voice-in-python

Upvotes: 1

user270073
user270073

Reputation: 21

May be possible to pass the gTTS output through Audacity and apply a change to a male-sounding voice? gTTS I have just got going has a very good female voice, but the engine fails to read well on long sentences or unexpected words. Still, it's the best I found for free so far, and actually is better than all the other free ones, and a good deal of the pay ones. I just had to work out the py scripts and how to use python and later learned Anaconda is a miracle cure to what ails you. Got my systems terminal and the pip to install gTTS properly, which I could not do prior to Anaconda. Scripts made by people for 3.+ now run without errors trying run them in default py v2.7. The terminal is now env 3.6.8 but also all the old py scripts still run fine.

Upvotes: 2

Kush
Kush

Reputation: 1036

Unfortunately it does not appear you can do that. The script uses this webpage to grab voice from, and it appears all you can do is have one voice per language.

Reading the actual source shows that your next best bet would be to try to pass a different language that is still English (for example, en-uk). It may produce a different result that is still English but with a different dialect.

Upvotes: 20

Related Questions