Вопрос

I have heard that appkit is included with PyObjC, so I installed with

$ sudo pip install pyobjc-core
$ sudo pip install pyobjc

And now when I go into Python:

>>> from AppKit import NSSpeechSynthesizer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named AppKit

Can someone help me with this?

Это было полезно?

Решение

Change AppKit to appkit, but you will still won't find NSSpeechSynthesizer there.

if you need NSSpeechSynthesizer, try this:

from Cocoa import NSSpeechSynthesizer

sp = NSSpeachSynthesizer.alloc().initWithVoice_(None) # use default voice
sp.startSpeakingString_("hello world")

Cocoa should be part of the PyObjC as far as I can understand.

source: http://code.activestate.com/lists/pythonmac-sig/23406/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top