RapidWareTech / pyttsx

Cross-platform text-to-speech wrapper
Other
370 stars 134 forks source link

runAndWait() doesn't return when calling say(..) with umlauts #29

Open datenstrudel opened 9 years ago

datenstrudel commented 9 years ago
engine = pyttsx.init()
engine.say("Bächtig möse")
engine.runAndWait() # <--- This call won't return

Hi, was just wondering why my program doesn't continue. Of course, quick fix is to just replace such characters before calling say(..). Don't know if there are other characters causing that behavior. Tested with python 2.7 under Windows 7

westonpace commented 9 years ago

Have you tried u"Bächtig möse"?

What you posted is not actually a valid Python 2.7 string (it will decode the 14 UTF-8 bytes into a 14 byte ASCII string) without the u prefix.

>>> x = "Bächtig möse"
>>> x
'B\xc3\xa4chtig m\xc3\xb6se'
>>> len(x)
14
>>> x = u"Bächtig möse"
>>> x
u'B\xe4chtig m\xf6se'
>>> len(x)
12

I have tested with the u prefix on my fork and know it works there but I cannot confirm if that is because of changes I have made on the fork or simply this u prefix issue.