pywinrt/python-winsdk

Missing SpeechSynthesizer.get_all_voices

n0h4rt opened this issue · 5 comments

As the title suggests, the SpeechSynthesizer does not have both the get_all_voices and get_default_voice methods.
The last known working version was 1.0.0b6.

import winsdk.windows.media.speechsynthesis as wms

synthesizer = wms.SpeechSynthesizer()

voices = synthesizer.get_all_voices()  # raises AttributeError

default_voice = synthesizer.get_default_voice()  # raises AttributeError
dlech commented

Static properties were "fixed" in beta 8 to be class attributes instead of methods.

synthesizer.get_all_voices() should be replaced with SpeechSynthesizer.all_voices and synthesizer.get_default_voice() should be replaced with SpeechSynthesizer.default_voice.

Same results.

AttributeError: 'SpeechSynthesizer' object has no attribute 'all_voices'
AttributeError: 'SpeechSynthesizer' object has no attribute 'default_voice'

Here is the dir().

import winsdk.windows.media.speechsynthesis as wms

dir(wms.SpeechSynthesizer)
# ['__class__', '__delattr__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_assign_array_', '_from', 'close', 'options', 'synthesize_ssml_to_stream_async', 'synthesize_text_to_stream_async', 'try_set_default_voice_async', 'voice']
dlech commented

Static properties won't show up in dir() because they are defined in a meta class.

Which version of Python and winsdk are you using?

dlech commented

Did you actually write SpeechSynthesizer.all_voices and not synthesizer.all_voices?

>>> import winsdk.windows.media.speechsynthesis as wms
>>> [x.display_name for x in wms.SpeechSynthesizer.all_voices]
['Microsoft David', 'Microsoft Zira', 'Microsoft Mark']

Which version of Python and winsdk are you using?

I'm using Python-3.10 and winsdk-1.0.0b8.

Did you actually write SpeechSynthesizer.all_voices and not synthesizer.all_voices?

I'm sorry, I didn't know that instantiated SpeechSynthesizer behaved differently than its constructor. I thought it was the same class.

[x.display_name for x in wms.SpeechSynthesizer.all_voices]

I just tested this and it works.
You have my thanks :)