Python中用于语音转文本的语音处理库
你好!
我想用Python写一段代码,让它能通过麦克风识别我说的话,然后把这些话转换成语音。你能推荐几个好用的语音处理库吗?
2 个回答
0
在提供代码示例的过程中,dragonfly的示例代码漏掉了一段代码,可以在这个链接找到:https://pythonhosted.org/dragonfly/
from dragonfly.all import Grammar, CompoundRule
# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
spec = "do something computer" # Spoken form of command.
def _process_recognition(self, node, extras): # Callback when command is spoken.
print "Voice command spoken."
# Create a grammar which contains and loads the command rule.
grammar = Grammar("example grammar") # Create a grammar to contain the command rule.
grammar.add_rule(ExampleRule()) # Add the command rule to the grammar.
grammar.load() # Load the grammar.
后面应该接着
import time
import pythoncom
while True:
pythoncom.PumpWaitingMessages()
time.sleep(.1)
正如这里提到的 - http://dragonfly.googlecode.com/svn-history/r46/trunk/dragonfly/examples/dragonfly-main.py