2

Dragonfly for Python を使用して、Windows 用のアクセシビリティ アプリのプロトタイプを作成しています。イライラすることに、Windows Speech Recognition (WSR) はコンピューターからの音声を認識します。これは、独自のエンジンによって生成された音声を認識するため、私にとって大きな問題です。たとえば、次を使用しspeakます。

e = dragonfly.get_engine()
e.speak("Welcome. What can I do for you today? Please say a command.")

WSR は、その無限の叡智により"Please say"、コンピューターのスピーカーから聞き取り、それを として解釈し"Yes"ます。プロンプトの文言を変更しましたが、これはプロトタイプの多くの部分で一貫した問題です。また、プロンプトを変更して"Affirmative"忘れないようにしたい"Yes"と思います。

これは私の単純な応答クラスがどのように見えるかです:

class SingleWordResponse(CompoundRule):
    spec = "<word>"
    extras = [Choice("word", {"no":0, "yes":1, "ready":1, "okay":1,"repeat":2})]
    mode = 0
    def _process_recognition(self, node, extras):
        #here I use self.mode to keep track of what the user is doing and respond based on the context

この望ましくない「機能」を無効にしたり回避したりするさまざまな方法を受け入れます。さまざまなコンテキストを使用してみましたが、contextドキュメントではその使用法があまり明確ではありません。これを防ぐために属性を設定しようとしましspeakingたが、うまくいかないようです。これはspeaking属性のテストです:

class SingleWordResponse(CompoundRule):
    spec = "<word>"
    extras = [Choice("word", {"no":0, "yes":1, "ready":1, "okay":1,"repeat":2})]
    speaking = False
    def _process_recognition(self, node, extras):
        if self.speaking == False:
            print "command recognized"
            #process command
        #otherwise do nothing

通話の直前にを設定しSingleWordResponse.speaking、直後に設定しましたが、役に立ちませんでした。Truee.speak()False

4

1 に答える 1