Question: Good afternoon, I'm learning and using pyttsx for speech, the thing is that I want to use it as a "female" voice but I can not do it using this code:

```
import pyttsx as pt
from pyttsx import voice
engine = pt.init()
voices = engine.getProperty('voices')
#engine.setProperty('gender', 'female') # also does not work
engine.setProperty('female', voice.Voice.gender) #not even
engine.setProperty('female', voice.gender) #does not work
engine.setProperty('voice', voices[4].id)
engine.say("Hello World")
engine.runAndWait()

class Voice(object):
    def __init__(self, id, name=None, languages=[], gender=None, age=None):
        self.id = id
        self.name = name
        self.languages = languages
        self.gender = gender
        self.age = age

```

Answer: 
Use `sound=getProperty ('voices'); engine.setProperty('voice','sound [1].id')`
This will definitely work. 0 for male and 1 for female.
I use this helper function, that iterates over the voices. If a voice for a specific language and gender exists, it will change to this voice otherwise an exception will be raised.

```
# language  : en_US, de_DE, ...
# gender    : VoiceGenderFemale, VoiceGenderMale
def change_voice(engine, language, gender='VoiceGenderFemale'):
    for voice in engine.getProperty('voices'):
        if language in voice.languages and gender == voice.gender:
            engine.setProperty('voice', voice.id)
            return True

    raise RuntimeError("Language '{}' for gender '{}' not found".format(language, gender))

```

And finally it will be used like this:

```
engine = pt.init()
change_voice(engine, "en_US", "VoiceGenderFemale")
engine.say("Hello World")
engine.runAndWait()

```