|
NaturallySpeaking Unofficial Information Pages
The Insider's Guide to Dragon NaturallySpeaking by Joel Gould |
Intro To PythonLast Modified: October 14, 2000 (Note: I have written two different introductions to NatLink, this page is written for NatSpeak users who want to know what this Python stuff is all about. The next page is written for Python users who want to know what this Dragon NaturallySpeaking thing is all about.)What is Python?Python is an interpreted, interactive, object-oriented programming language which has become increasing popular. Many people compare Python to Perl, and although Python can do most of the tasks that Perl can do, Python is richer and more powerful. Python is available on most computing platforms, although only the Windows version is of interested to users of Dragon NaturallySpeaking. Python is copyrighted but is freely usable and distributable, even for commercial use. Because Python is interpreted and because Python easily interfaces to other systems by using C extension modules, Python makes an ideal macro language for other programs, including Dragon NaturallySpeaking. It is relatively easy to learn and very powerful. And with NatLink, my interface between Python and Dragon NaturallySpeaking, you can use Python to write macros which are a lot more powerful and flexible than macros written using the build-in NatSpeak macro language. You can learn all about Python from the main Python web site: http://www.python.org/. You will not have to become a Python expert in order to use Python as a macro language for Dragon NaturallySpeaking. I provide enough examples which you can modify that you should be able to get started with little or no trouble. But you will need to know the basics of Python so I recommend a book. There are two books which teach Python. The book I recommend is called Learning Python (Mark Lutz, etc.). This is a newer book (which means that it is more up to date with the latest version of Python). It also seems to be better suited to learning the language from scratch. The other big Python book is Programming Python (Mark Lutz). This is a larger, more through treatment of the language. But it is older so it is a little out of date in spots. It is also a little harder to get through since it covers more advanced topics. One other Python book you may find interesting is Python Programming for Win32 (Mark Hammond, Andy Robinson). This book includes the details of how to use Python more effectively under Windows. It includes details about controlling Word, Excel, etc. from Python using OLE Automation, which you may find useful if you want to speech enable Windows applications. What is NatLink?NatLink is a C++ program which extends the Python programming language so you can access and control Dragon NaturallySpeaking directly from Python. NatLink is also a Dragon NaturallySpeaking compatibility module. This means that Dragon NaturallySpeaking will automatically load NatLink and use NatLink to communicate with one or more applications. The term compatibility module is not very common but you have used them before. NaturalText is the most obvious compatibility module. It is automatically loaded when Dragon NaturallySpeaking starts and allows you to dictate into 3rd party applications by sending them keystrokes. NaturalText also contains the code which interprets macros from the global.dvc file. All built in macros, and any macros you write using the Professional Edition are executed using the NatLink compatibility module. NatLink is another compatibility module like NaturalText. When installed, NatLink will allow you to load and recognize command grammars which are defined in one or more Python source files. Then, when your commands are recognized, your Python code is called to perform the appropriate actions. NatLink does not replace NaturalText or Dragon NaturallySpeaking's built-in command and control system. Instead, NatLink coexists with it (as long as the command phrases you write in Python are different than the command phrases built-in to NatSpeak or added to your global.dvc file.) In addition, using NatLink and writing your macros in Python has a number of advantages over writing your macros in the Dragon NaturallySpeaking native command and control language.
Of course there is a down side. Here are some things which you should be aware of if you decide to use NatLink and Python to write macros:
More DetailsI have given two PowerPoint presentations on the NatLink Python Macro System which you may find instructive. The first presentation, NatLinkTalk.ppt, is an overview of how to use NatLink to write macros for Dragon NaturallySpeaking. It was first given to the Boston Voice Users group in the fall of 1999. Then I updated the talk a little and gave it to the Voice Coders group in June of 2000. The second presentation, VoiceCoders.ppt, is more advanced. It describes how one could use NatLink and Python to replace the dictation components of Dragon NaturallySpeaking with their own dictation subsystem. Although I do not expect the average user to rewrite NatSpeak's dictation subsystem, the talk does include interesting technical details about how NatSpeak works which may be of interest to a broader audience. That said, you are ready to move on. Skip the next topic which was written for Python programmers who need to learn about Dragon NaturallySpeaking and move ahead to NatLink Copyright. This web page (http://www.synapseadaptive.com/joel/IntroToPython.html) was last modified on October 14, 2000. The contents of this page are (c) Copyright 1998-1999 by Joel Gould. All Rights Reserved. See Copyright Information for more details. |