Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make various changes to the SAPI 5 engine backend and test suites #58

Merged
merged 6 commits into from
Jan 28, 2019

Conversation

drmfinlay
Copy link
Member

Re: #41, dictation-toolbox/Caster#305.

I've made various changes to the SAPI 5 engine backend and test suites:

  • Add test suite for Sapi5InProcEngine.
  • Add tests for recognition observers in test_engine_sapi5.py.
  • Change default engine class for SAPI5 to Sapi5InProcEngine. This is being done to work around a few problems with Sapi5SharedEngine (e.g. Grammars with Sapi5SharedEngine containing rules with <n> do not load. #41), although that class can still be used.
  • Make SAPI 5's mimic method work synchronously by using code from ElementTester.
  • Remove engine-specific logic from ElementTester and RuleTestGrammar classes, assume engine.mimic() works properly for all engines.
  • Remove/workaround SAPI 5 recognition results limitation.
  • Update documentation for SAPI 5 engine backend and test suites.

I have all but two of the unit tests passing with both the in-process and shared process engine classes: the engine timer tests and a doctest for RuleRef elements. The test suites can be run with the following commands:

python setup.py test --test-suite=dragonfly.test.suites.sapi5inproc_suite  # in-process class
python setup.py test --test-suite=dragonfly.test.suites.sapi5_suite  # shared process class

Tests should be run with your microphone muted to prevent audio interfering with tests. There are some more instructions for testing the shared process class here.

The timer tests are easy to fix, however I'm not sure why the RuleRef test is failing. I excluded test_dictation.py because SAPI5 doesn't seem to handle accented characters.

One other thing to note is that RecognitionObservers behave strangely with WSR. You should be fine as long as you don't rely on a set number of calls to notify_begin() or notify_failure(), they are sometimes called multiple times.

@comodoro @LexiconCode Sorry I took a while to get to this, I wanted the test suites working properly beforehand. So far I've only tested on Windows 10, so if you're running an older version please let me know if more tests fail.

- Add test suite for Sapi5InProcEngine.
- Add tests for recognition observers in test_engine_sapi5.py.
- Change default engine class for SAPI5 to Sapi5InProcEngine.
  This is being done to work around a few problems with
  Sapi5SharedEngine, although that class can still be used.
- Make SAPI 5's mimic method work synchronously by using code from
  ElementTester.
- Make other minor changes to suites.py.
- Remove engine-specific logic from ElementTester and RuleTestGrammar
  classes, assume engine.mimic() works properly for all engines.
- Remove/workaround SAPI 5 recognition results limitation.
@drmfinlay drmfinlay added the Windows Speech Recognition Issues related to Windows Speech Recognition label Jan 20, 2019
@drmfinlay drmfinlay self-assigned this Jan 20, 2019
- Move TextTimerManager class into engines.base.timer as
  ThreadedTimerManager and adjust backend_text.
- Stop requiring engine.connect() before using timers with the
  manager class. This is an unnecessary limitation.
- Timeout thread.join() after 5 seconds to prevent the main thread
  hanging if timers are misused.
- Use ThreadedTimerManager in SAPI 5 engine backend.
This is only necessary for the SAPI 5 in-process engine class.
- Add additional test method for dictation elements into SAPI 5
  tests.
- Change rule ID generation in SAPI 5 compiler to work with
  dictation elements and dragonfly lists.
- Remove unused variables and imports in SAPI 5 engine file.
@drmfinlay
Copy link
Member Author

Both failing tests are fixed now. Everything passes using either engine class on Windows 7 and 10. I have also fixed an issue with dictation not working correctly and added a test for it in test_engine_sapi5.py. There were some intermittent test failures using the shared process engine.

Issue #41 is still not resolved by these changes. I believe it to be an issue with WSR itself rather than dragonfly. Using the in-process engine instead should be good enough now.

I think this is ready for merging. There should be a new release soon.

@LexiconCode
Copy link
Member

Sounds good I'll try testing it out today!

@LexiconCode
Copy link
Member

I'm having issues with Git, so go ahead and merge. We can always release a hot fix if there's something critical and Caster will need a few adjustments anyway to work.

@drmfinlay
Copy link
Member Author

All right then, sounds good. Let me know if you need help with that :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Speech Recognition Issues related to Windows Speech Recognition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants