10

Dragonflyモジュールの使い方を理解しようとしています。ドキュメントを確認しましたが、使い方がわからないようです。いくつかのフレーズを認識して、それらのフレーズに基づいて行動できるようにしたいと思います。

4

3 に答える 3

5

そうです、この例は終了します。私はこの特定の例をかなり見てきましたが、いくつかの重要な機能が欠けています。

まず、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)
于 2013-04-09T22:20:01.507 に答える
3

まず、Linuxを使用している場合、DragonflyはWindows音声認識またはDragon NaturallySpeaking+ Natlinkでのみ機能することを知っておく必要があります。(仮想マシンとAeneaを使用してLinuxで動作させることは可能ですが、それはこの質問の範囲外のようです。)

WSRで使用している場合は、DragonflyがPythonパスにあることを確認し、メインスクリプトの最後で次のコマンドを呼び出すだけの簡単なものにする必要があります。

while True:
    pythoncom.PumpWaitingMessages()
    time.sleep(0.1)

Dragon NaturallySpeakingで使用している場合は、Dragonflyを使用する前に、上記のリンクからNatlink Webサイトにアクセスし、そこにある指示に従ってNatlinkをインストールしてアクティブ化してください。インストールすると(すべてのデフォルトを使用)、DragonflyスクリプトをC:\ NatLink \ NatLink \ MacroSystemフォルダーに配置し、DragonNaturallySpeakingを起動したときに自動的にアクティブ化できるようになります。

于 2014-11-13T00:21:09.587 に答える
1

このドキュメントに記載されている使用例は、非常に単純で自明であることがわかります。

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.
于 2013-03-22T11:39:45.110 に答える