문제

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