dictation-toolbox / dragonfly

Speech recognition framework allowing powerful Python-based scripting and extension of Dragon NaturallySpeaking (DNS), Windows Speech Recognition (WSR), Kaldi and CMU Pocket Sphinx
GNU Lesser General Public License v3.0
388 stars 75 forks source link

Clarify `Playback` documentation #270

Closed LexiconCode closed 4 years ago

LexiconCode commented 4 years ago

When you give dictation with the proper noun like Buffalo Bills that's capitalized by DNS in free dictation not as a command it causes playback to fail.

In Caster we have a command called again do

It retrieves raw recognition history from from dragonfly import RecognitionHistory

It does postprocessing to ensure that each word is an element in a list and subtracts again do from the recognition index.

drmfinlay commented 4 years ago

Thanks for reporting this. I'll look into it. What stands out to me is Buffalo Bills being one "word" in the recognition history and two words after processing. I don't know if that's related.

LexiconCode commented 4 years ago

That's a good point about it being two words and that DNS might expect that. That should be easy enough for me to test and let you know

LexiconCode commented 4 years ago

Well a couple of notes here

        'buffalo bills':
            R(Playback([(["buffalo", "bills"], 0.0)])), 
Traceback (most recent call last):
  File "C:\Python2\lib\site-packages\dragonfly\engines\backend_natlink\engine.py", line 411, in results_callback
    func, words=tuple(map_word(w) for w in results.getWords(0)),
  File "C:\Python2\lib\site-packages\dragonfly\engines\backend_natlink\engine.py", line 411, in <genexpr>
    func, words=tuple(map_word(w) for w in results.getWords(0)),
  File "C:\Python2\lib\site-packages\dragonfly\engines\backend_natlink\engine.py", line 60, in map_word
    if isinstance(word, text_type):

Recursion error can be caused by the following. The command repeats itself 71 times before trace back is produced. Not directly related to the issue but interesting to note.

 'buffalo bills hello':
            R(Playback([(["Buffalo Bills"], 0.0)])),  

These issues came about due to incorrect assumptions about the playback.

I suppose one of my unconscious assumptions about Playback is if it failed has a command it would print out as free dictation with DNS. Clearly by the tests above this is not the case. I believe this internal assumption came about the playback command didn't find a command and the playback was defined by lowercase words it would simply print out as free dictation.

I will look into Casters postprocessing function could be fixed to just remove the again do without disturbing the engines expected format from history. The assumption being the history reported is always valid for dragonfly playback per back-end.

You might want to update the title to what you feel best reflects the issue at hand. if you feel more in depth testing is needed I could view the these tests through debugging.

drmfinlay commented 4 years ago

Sorry for the late response. I don't understand why DNS is picky with capitals like this. I'm happy to update the documentation.

The recursion error is expected in the case where you recognise "buffalo bills" and then mimic it again. An exception caught and displayed by Natlink is certainly better than it looping forever. 😉

drmfinlay commented 4 years ago

I think these things should be documented in a new page for the Natlink engine back-end. The documentation for Playback and Mimic can then reference that page.

Some of the other engine back-ends also have quirky mimic behaviour, e.g. SAPI 5 sometimes fails to mimic commands for no discernible reason. The SAPI 5 engine back-end's mimic() method can actually crash Python in certain situations. I'll put together a new page for that engine as well.