python - 您如何使用 Python 模块 Dragonfly 识别语音?

标签 python speech-recognition python-dragonfly

我一直在努力弄清楚如何使用 Dragonfly 模块。我已经查看了文档,但似乎无法弄清楚如何使用它。我只想能够识别一些短语并根据这些短语采取行动。

最佳答案

没错,这个例子将会终止。我已经多次看到这个特定示例,但它缺少一些关键功能。

首先是没有导入pythoncom。这为程序提供了一个主循环。以上

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.

while True:
    pythoncom.PumpWaitingMessages()
    sleep(.1)

关于python - 您如何使用 Python 模块 Dragonfly 识别语音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3644129/

相关文章:

python - 从 Dragonfly 语音识别引擎获取文本

python - 事件处理 : Matplotlib's Figure() and pyplot's figure()

c# - 单个单词的 Microsoft 语音识别

c# - Microsoft Speech Platform 11(服务器)上的 AppendDictation?

javascript - 如何让语音识别持续固定时间段?

python - 使用 Dragonfly 禁用 Windows 语音识别

windows - 在windows10中安装python2.7的natlink和dragonfly

Python2 __base__ 和 super

python - 在 ubuntu 上添加 python 3.10

python - 如何使用 python pandas 库改变数据