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

Error in natlink engine.py: AttributeError: 'DictListRef' object has no attribute 'list_' #338

Closed wolfmanstout closed 3 years ago

wolfmanstout commented 3 years ago

I'm not sure what triggered this, but I saw this in my Dragonfly log:

Traceback (most recent call last):
  File "c:\users\james\projects\dragonfly\dragonfly\engines\backend_natlink\engine.py", line 544, in results_callback
    if self._process_rules(words, words_rules, results, True):
  File "c:\users\james\projects\dragonfly\dragonfly\engines\backend_natlink\engine.py", line 476, in _process_rules
    rule_words = self.get_rule_words(r)
  File "c:\users\james\projects\dragonfly\dragonfly\engines\backend_natlink\engine.py", line 445, in get_rule_words
    words.update(self.get_rule_words(element.rule))
  File "c:\users\james\projects\dragonfly\dragonfly\engines\backend_natlink\engine.py", line 445, in get_rule_words
    words.update(self.get_rule_words(element.rule))
  File "c:\users\james\projects\dragonfly\dragonfly\engines\backend_natlink\engine.py", line 447, in get_rule_words
    for string in element.list_.get_list_items():
AttributeError: 'DictListRef' object has no attribute 'list_'

Looks like this originates from the code in this 10-month-old commit from @Danesprite: https://github.com/dictation-toolbox/dragonfly/commit/0118da3a2a36fd62555d6a3385bb0b19025e238d

I think it might just need an additional case for DictListRef? I was tempted to make the change myself but I don't really understand this code (e.g. why it is only using the first word).

drmfinlay commented 3 years ago

Ah, thanks for reporting this. This is very simple to fix; element.list_. should be element.list. instead.

This code was added as a workaround for when DNS doesn't report a difference between command and dictation words. Dragonfly requires distinct rule IDs to successfully process commands where the special <dictation> rule is used. This happens more with recent DNS versions, I think. The related issue is #242.

This bug will have occurred because you use Dragonfly Lists/DictLists. I added some code for including current list words in the set of command words for each rule, but clearly I did not test the code properly before merging! Sorry about that!

Only the first words of literals and list items are used so that any further words are not unnecessarily included in the set. This limits the set of spoken words that, in the event this workaround code is run, cannot be processed properly as dictation words. Unfortunately, this fix is not perfect. It was easier than rewriting Dragonfly's decoding framework, however.

drmfinlay commented 3 years ago

I'll release the fix for this shortly in version 0.31.1.