Python中的Speech-to-tex语音处理库

2024-04-19 04:26:30 发布

您现在位置:Python中文网/ 问答频道 /正文

嘿 我希望用python构建一个代码,它可以识别我通过micrphone所说的内容并转换成语音, 你能给我几个有效的语音处理库吗??


Tags: 代码内容语音micrphone
2条回答

蜻蜓示例代码在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

相关问题 更多 >