【发布时间】:2012-09-27 08:07:02
【问题描述】:
Python 中是否有任何库可以使用 Mac Lion 的内置文本到语音引擎执行或允许文本到语音转换? 我做了谷歌,但大多数都是基于 Windows 的。我试过pyttx。 我试着跑了
import pyttsx
engine = pyttsx.init()
engine.say('Sally sells seashells by the seashore.')
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
但我得到了这些错误
File "/Users/manabchetia/Documents/Codes/Speech.py", line 2, in <module>
engine = pyttsx.init()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyttsx-1.0.egg/pyttsx/__init__.py", line 39, in init
eng = Engine(driverName, debug)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyttsx-1.0.egg/pyttsx/engine.py", line 45, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyttsx-1.0.egg/pyttsx/driver.py", line 64, in __init__
self._module = __import__(name, globals(), locals(), [driverName])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyttsx-1.0.egg/pyttsx/drivers/nsss.py", line 18, in <module>
ImportError: No module named Foundation
如何解决这些错误?
【问题讨论】:
-
当然你可以使用 OSX
say命令? -
@MartijnPieters:我用谷歌搜索并尝试了 pyttx,但出现错误。
-
@ManabChetia:这是一个实质性的区别,现在你有一个实际的问题! :-)
-
Foundation是pyobjclibrary 的一部分;你安装了吗?它默认带有 system python,但我看到你安装了自己的 Python 2.7。 -
@MartijnPieters:我还没有安装它。所以我现在需要输入
easy_install pyobjc?
标签: python macos text-to-speech