@@ -139,6 +139,38 @@ the following resources from might be of use:
139
139
* `Latest Python documentation <https://docs.python.org>`__
140
140
141
141
142
+ .. _RefFAQSupportEngineX:
143
+
144
+ Will Dragonfly add support for speech recognition engine X?
145
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146
+
147
+ We are not considering the addition of new Dragonfly engine implementations.
148
+ The main reason for this is that Dragonfly requires a very specific type of
149
+ speech recognition engine to work. It must be one which supports each of
150
+ the following features:
151
+
152
+ 1. definition of voice commands in a grammar format
153
+ 2. efficient and dynamic activation and deactivation of (parts of) grammars
154
+ at the beginning of an utterance
155
+ 3. in-speech transition between dictated prose (dictation mode), loaded
156
+ voice commands (command mode) and vice versa
157
+
158
+ Each Dragonfly engine supports features one and two. All engines support
159
+ feature three except the CMU Pocket Sphinx engine. However, Sphinx is
160
+ only limited in that dictated prose must be spoken in separate utterances.
161
+
162
+ These three requirements have effectively ruled out Dragonfly support for
163
+ most speech recognition engines that users have asked about in the past.
164
+
165
+ Even if a new speech recognition engine comes along that supports the above
166
+ features, we will probably not accept an engine implementation for it
167
+ because Dragonfly already has very good engine implementations.
168
+
169
+ We may make an exception for new implementations meant to replace current,
170
+ deprecated ones. However, none of Dragonfly's current engines really need
171
+ replacing.
172
+
173
+
142
174
API Questions
143
175
----------------------------------------------------------------------------
144
176
@@ -320,6 +352,61 @@ prints the name of the current engine if one has been initialized:
320
352
print("No engine has been initialized.")
321
353
322
354
355
+ Can I implement my own custom Dragonfly engine?
356
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
357
+
358
+ Yes, this is possible. Although Dragonfly is :ref:`not accepting new engine
359
+ implementations <RefFAQSupportEngineX>`, you can write one externally,
360
+ register it and use it like any of the in-package engines.
361
+
362
+ Implementing a custom Dragonfly engine is a complex task. It is
363
+ recommended that you start with a copy of the text-input engine source code
364
+ and make alterations with reference to the code of other engines. The
365
+ text-input engine source code may be consulted via the source code links on
366
+ :ref:`this page <RefTextEngine>`.
367
+
368
+ If you want to customise say, the Natlink engine, start with the code (or
369
+ classes) for that engine instead.
370
+
371
+ Once you have implemented the required engine methods and classes, you'll
372
+ need to register an engine instance with the special
373
+ ``register_engine_init`` function:
374
+
375
+ .. code-block:: python
376
+
377
+ from dragonfly.engines import register_engine_init
378
+ my_engine = MyEngine()
379
+ register_engine_init(my_engine)
380
+
381
+ Your engine instance will then be returned by Dragonfly's ``get_engine()``
382
+ function, when it is invoked:
383
+
384
+ .. code-block:: python
385
+
386
+ >>> from dragonfly.engines import get_engine
387
+ >>> get_engine()
388
+ MyEngine()
389
+
390
+ Your engine implementation should now be useable. Please note, however,
391
+ that you won't be able to use it with Dragonfly's :ref:`RefCLI` or test
392
+ suite without a few modifications.
393
+
394
+ In order to use your engine with these facilities, an instance of your
395
+ engine must be registered and have a unique name *before* the
396
+ ``get_engine()`` function is invoked by them. In addition, if you want to
397
+ test your implementation against Dragonfly's test suite in a clone of the
398
+ git repo, you will need to add an entry to the special
399
+ ``engine_tests_dict``:
400
+
401
+ .. code-block:: python
402
+
403
+ # Do this in setup.py around line 59 or in an imported module.
404
+ from dragonfly.test.suites import engine_tests_dict
405
+ my_engine_tests = engine_tests_dict['text'][:]
406
+ my_engine_tests.remove('test_engine_text') # Replace with test_engine_<name>.
407
+ engine_tests_dict[my_engine.name] = my_engine_tests
408
+
409
+
323
410
Troubleshooting Questions
324
411
----------------------------------------------------------------------------
325
412
0 commit comments