Jiangshan00001 / pyttsx4

Offline Text To Speech synthesis for python
Mozilla Public License 2.0
43 stars 8 forks source link

Language property of voices is broken #6

Closed ekalosak closed 1 year ago

ekalosak commented 1 year ago

Describe the bug The languages property of voices is a list containing just the voice ID, not the language.

To Reproduce

import pyttsx4
engine = pyttsx4.init()
for voice in engine.getProperty("voices"):
    print(f"voice={voice}")
    for lang in voice.languages:
        print(f"lang={lang}")

Notice the error in the lang={lang} output lines, for example:

voice=<Voice id=com.apple.speech.synthesis.voice.zosia
          name=Zosia
          languages=['com.apple.speech.synthesis.voice.zosia']
          gender=VoiceGenderFemale
          age=35>

Expected behavior Languages should be languages, not voice ID's.

Jiangshan00001 commented 1 year ago

i see your code. it is good, and the old code is something wrong. the old code is: attr.get('VoiceIdentifier',attr.get('VoiceLanguage')) new code is: attr.get('VoiceLanguage')

could you change your pull request to: attr.get('VoiceLanguage', attr.get('VoiceIdentifier')) in case there is no 'VoiceLanguage', the 'VoiceIdentifier' will be used. or, am i miss something, that the key 'VoiceLanguage' MUST not be missing forever? thanks.

ekalosak commented 1 year ago

Regarding the notion that VoiceLanguage must not be missing - I opted for this approach because, as a pyttx4 user, I would rather see an error indicating a missing language attribute than for the pyttx4 code to produce unexpected behavior (by, in this case, tricking me into thinking a language is available - but instead the attribute has an invalid value).

Jiangshan00001 commented 1 year ago

fine