Friday, July 03, 2009

LVSpeak: Automating VI development through speech

Eyes on VIs is pleased to welcome its first guest blogger, Norm "The Captain" Kirchner! Norm is the first person in history to sacrifice his LabVIEW Champion status for the pleasure of working at National Instruments. (NI Employees cannot be LabVIEW Champions). Norm has been using LabVIEW for over 9 years and he is going to share his "LVSpeak" project, which (I hope you will agree) is pretty darn amazing. Thanks for joining us, Norm!

- Christina




Imagine if LabVIEW was able to read your thoughts and react to them. You just think “edit icon” and *pop* the icon editor is opened for you immediately. Imagine if every time you wanted to drop a property node for a control or group of controls, they just showed up on the diagram.

Although this ability is not implemented in LabVIEW yet, we can get darn close by using our voice and a little creative coding.

LVSpeak (LabVIEW Speak) is a very simple concept with a great deal of possibilities. It utilizes the Microsoft Speech API (SAPI) and provides an open and extendable interface to it within LabVIEW. Currently, two extensions of that architecture exist. They are ‘Quick Edit’ and ‘Speech Enabled Quick Drop’.

These extensions of LVSpeak and the LabVIEW development environment give the coder tools to greatly speed the process of code creation and modification upwards of 70%.


Note: Volume on the videos is very low, turn speakers all the way up


Video 1: Code creation


WHY

LabVIEW is an easy to use and intuitive application development environment and programming language, but there are still some basic actions that require multiple clicks and force the user to navigate through a variety menus and options.

LVSpeak was developed to take those minor but time consuming steps and reduce them to a single voice command. At the root of this entire effort is one simple premise, “A good engineer is a lazy engineer”. And until we can program LabVIEW with our minds, turning a 4 step, 3 second action into a ½ second, 1 step voice command, makes me a happy lazy engineer.

At the end of the day, any action that requires you to remove your hand from the mouse (Ctl+I), or needs more than two mouse clicks and navigation deeper than a top level context menu (Label Visible) is warranted to become a Voice Command

HISTORY

When LabVIEW Scripting was still very new in LabVIEW 7.0 and some of it’s functionality was accidentally exposed by NI, it occurred to me that you could combine this scripting ability to use LabVIEW code to write LabVIEW code along with the free Microsoft speech recognition technology and do some creative things. Although an interesting idea, integrating dll’s and ActiveX objects into G was still foreign to me and presented a barrier that caused LVSpeak to sit dormant until NI Week 2008 and the release of Quick Drop.

Almost immediately I recognized a synergy between this great new development tool in LabVIEW and the still undeveloped LVSpeak. This was only confirmed further when I was watching the coding challenge at NI Week 08. During the coding speed challenge, the creator of Quick Drop, Darren Nattinger, was slowed to a crawl when doing simple tasks like creating a constant or typing verbose function names in the Quick Drop window.

At that point I realized that all the components needed, to allow the developer to program as fast as they could imagine the code, were in place.

HOW

The how is actually more simple than I would like to admit.

There are two key components to the Microsoft SAPI that are utilized in LVSpeak

  • Grammar List
  • 'Speech Recognized’ .NET Callback Event

Within LabVIEW, two components are required to enable speech recognition in any program.

  • Load Command List (Grammar)
  • Register for speech recognized event

The way everything plays together is quite simple

LVSpeak Core starts and

  1. Initializes the Microsoft SAPI
  2. Creates a LV User event
  3. Registers a callback VI to be run when speech is detected and fire the LV User Event with the command

Programs utilizing LVSpeak
  1. Register for the Grammar Detected event
  2. Load their command list into the “Grammar”
  3. Catch the fired event and respond accordingly to the string

For speech enabled Quick Drop, the grammar list is everything in the function palette, and whenever the LVSpeak event is caught, it takes the detected string and loads it into the text box as if you had just typed it.

Quick Edit follows that same flow. The grammar list is all created Quick Edit commands pulled from an enumeration. When one of those commands is detected, it runs the corresponding code to execute that command.



Video 2: Basic detection

Video 3: Quick Edit Demo


Getting Started

To start developing LabVIEW with your voice you need to download and install

Once all these parts are installed, you should see a new item in your LabVIEW tools menu "Enable LVSpeak"


Select that option, and you should see two floating windows show up.
If you microphone is active, manually drop some controls on your front panel, flip over to the block diagram, select all the controls and say "Label Side" in a relatively monotonic voice.



Summary


If you program LabVIEW on a regular basis, begin paying attention to how long some tasks take and how often you repeat some basic tasks that could be streamlined by a little scripting automation.


Controlling LV with your voice is not just a novel idea.
It is truly a quantum leap forward in how you develop your code and a HUGE performance booster.

So wipe the dust off of your microphone or headset and get ready to take your development process to the next level.

~,~
The Captain Was Here

Norm Kirchner

PS Thank you Christina for your patience with me getting this out to you and providing a great resource for the rest of us LabVIEW nuts out in the world.

Labels: , , , ,

24 Comments:

Anonymous Anonymous said...

I installed this on a Vista-machine with LV 8.6.1. Vista's in-built voice recognision works fine on the machine, but LVSpeak does not seem to catch any commands at all. Is the fact that I'm using the in-built voice recognision a problem? The 2 LVSpeak windows show, but nothing happens when I speak commands. I tried debugging the .Net component calls, but no errors...

7:08 AM, July 06, 2009  
Anonymous Matt Holt said...

I debated on whether to comment or not over the weekend. I decided that feedback in a constructive manner would likely be welcome, having said that:

I don't see this as a useful tool or addition to LabVIEW (as neat as it might be). I guess I'm really missing your target audience. In my role as a software development supervisor, SPEED is the least of my concerns (Accuracy of the delivery date is KEY). I'd be really curious to have a community discussion the topic of NI's current "do it fast" campaign is in the industry versus in demonstrations of some really fast code challenges.

I'd be open to more explanation from industry as to how this might be useful, but at this point I don't really see it.

The article hints at adding this into LabVIEW (the yet comment). Please consider making this an optional plug-in if it does make the cut.

8:30 AM, July 06, 2009  
Blogger Norm Kirchner ~,~ said...

Anonymous,

Although not well noted in the text, in the loading commands video you would have heard me mention that it is necessary to hold down the Ctl key to activate the "Speech Recognized Event".

Since you are having issues I would recommend keeping the ctl key held down well past when you are done w/ the command.

Let's try that first and then evaluate if it's a conflict w/ the built-in Vista system. (I don't believe it is because I'm on vista and had that active at the same time for a few months)

8:54 AM, July 06, 2009  
Blogger Norm Kirchner ~,~ said...

Matt,

First let me qualify the activity being done on this as personal activity. I may update the lead-in to this post to mention that I am not a member of the LabVIEW team or in R&D at NI. I have been programming with LV for a long time and only recently started working at NI. LVSpeak is not currently on any roadmap for native integration with LabVIEW (nor is it part of a "do it fast" campaign).

That being said, if you do not develop with LV on a regular basis the pain points that this resolves might not hit home. If you or your team do not take advantage of the quick drop window, then being able to speed up that process won't mean much.

But being able to speed up the interaction with quick-drop and being able to call custom scripting commands to automate the development process can have a very big impact on the flow of programming.

The target audience is LabVIEW developers. Anyone who drops a node on the block diagram, makes a label visible or invisible, or wants to easily execute operations en-mass on a group of controls (Label Side).

If the developer is currently not slowed down by simple operations like browsing the function palette or basic manipulation of Block Diagram nodes, then it would be difficult to see the value (vs the novelty) in this. But if they are like me, and get frustrated by being slowed down for basic or repetitive operations, then I would recommend evaluating it.

A good parallel kind of technology is 'hot keys'. Imagine if every time that you wanted to clear all broken wires, you had to go to the menu options instead of just pressing Ctl+B. Or that every time you wanted to go back and forth between the Block Diagram and Front Panel you could not use Ctl+E and instead had to go to the Window menu. Yes, you can do either, but which is less obtrusive to your interaction. Yes, both of the implementations work, but the developer can be much faster with a little knowledge of what the hot keys are.

I am not expecting LVSpeak to be used in a deliverable to a customer, although it could be. It is intended for the LabVIEW developer who sees the benefit of developing more efficiently.

And thank you for the constructive feedback. I do welcome it and perhaps it warrants a follow up post showing some real side by side situations instead of the simple examples I showed.

9:40 AM, July 06, 2009  
Anonymous Matt Holt said...

Norm:

Thanks for the response!

As you mentioned, while I am a LabVIEW developer, I haven't embraced quick drop for very similar reasons I mentioned... LabVIEW is already so much faster to develop in versus alternatives that a few seconds doesn't really mean much to me. I'm one of those people who come in to work and have Visual Studio and LabVIEW up all day... the inherent speed of programming in LabVIEW is already enough of a benefit that making it faster doesn't really seem very lucrative...

I'm really looking forward to seeing how you designed this to be used in more detail, I'm probably WAY off in my expectations.

10:04 AM, July 06, 2009  
Blogger Alan said...

This is even better than roll over buttons! I had three issues in making LVSpeak work. (1) It requires .NET Framework 3.0 or greater. The new machine that I installed it on with XP SP3 only had .NET 2.0. (2) Not knowing to hold the control key. Doh!(3) It's not working with the Quick Drop. What am I missing here?

2:16 PM, July 06, 2009  
Blogger Mads said...

The demo video got me so excited I went out and bought a microphone right away (I had seen the post on LAVA, but back then I did not try it).

I ended up dropping the idea of using it regularly because of the way it is implemented: It's too cumbersome to have to open the Quickdrop window before speaking the commands (pressing Ctrl is OK, even though I would love to skip even that), the two open windows are annoying...and once you begin using it you very quickly get irritated (ironically) because you want more...(creating and setting up property nodes with a single command e.g.).

Do not get me wrong - I think this is great stuff - fantastic work by you Norm. I just hope someone will bring it even further - if it can do more and is better integrated into LV I would gladly pay to get a copy:-)

4:09 AM, July 07, 2009  
Blogger Norm Kirchner ~,~ said...

Alan,
1. Not much way around this unless we get some wiz doing voice recognition in pure LV (interested?)
2. Yeah, I apologize again for not giving specific instructions on this, but expect to give a follow up post.
3. Not working w/ quick drop? did you install both packages? Are the other commands working? Make sure you give it ample time after you get QD open the first time but I wouldn't expect it would be that much. Ping me on LAVA for more support.

5:14 PM, July 07, 2009  
Blogger Norm Kirchner ~,~ said...

Mads,
Thanks for the encouragement. I would not object if somehow my paypal account got a mystery deposit (JUST KIDDING DR T ;)

That aside, you only need the quickdrop window open when you want to drop new nodes and not when doing quick edit commands. Can't get around that, not in the mood to re-create a headless quick drop. And if you're peeved about the first load time of QD, make sure to go to LV>>Tools>>options and load palettes at launch. You do NOT want it to constantly translate for 1 MAIN reason (and a few smaller ones)....Delete is now a command and I don't think you want a false translation just because you said something like delete and lose code.

And with regards to wanting more.... that is exactly how the list of commands has grown so fast! Every time I find something I want that is missing... I just make it. Get up to speed on scripting or get active w/ requesting how to do things on the scripting board and toss it into the quick edit environment and add a command to the enumeration.

Enjoy!

5:21 PM, July 07, 2009  
Blogger Mads said...

Norm,

I did do some modifications - everything now runs in the background and I've joined the core and the command handlers into one "main".

The latter was done just to make it easier to have an overview of the parts of the system. (I've done this without any thorough analysis of the code, just trial and error, so perhaps there are implications I have not foreseen, but it does not look like it, things run smoothly so far.

Adding new functionality is, I can see, very easy. Now all I need is some time to spare...:-)

5:53 AM, July 08, 2009  
Blogger K1200LT Rider said...

Will it work at all with LV versions previous to 8.6?

I would like to try this, but only at home. I don't think the cubicles around me would appreciate my constant "talking to myself."

I can see great potential for certain types of applications, though.

- Brad

7:17 AM, July 08, 2009  
Blogger Norm Kirchner ~,~ said...

Mads,
I would keep two things in mind with this.

In order for quick-drop to work properly, the LVSpeak Core needs to be run in the LV.Editor context. You might have noticed that upon running the Tools>>Enable LVSpeak that a launcher program briefly runs. This program is what sneaks LVSpeak and QE into the LV.Editor context. If you don't plan to use speech w/ quick drop then it shouldn't matter.

Once upon a time it was just one program, but to make the architecture more modular I designed it so that the recognition engine was fully de-coupled from any thing else that used it. Just a smarter design.

Truly what Quick-Edit warrants is a plug-in design, and it is in the plans but not yet timeline.

9:25 AM, July 08, 2009  
Blogger Norm Kirchner ~,~ said...

K1200LT Rider,

In a follow up post, I'll give some video demos showing me utilizing it. And for sure you will barely be able to hear me talking. It turns out that the recognition system in conjunction w/ a headset needs just a whisper to detect a command well. In fact, it seems to work better the lower and softer I talk to it.

And it does not require some kind of fancy headset or mic either. I'm using a Logitech POS that I got for 13 bucks.
http://tinyurl.com/mnbsnm

So don't be afraid of speaking sweet nothings to your computer. All that anyone will see is you softly mumbling under your breath, and if you're using Vista....that's par for the course

9:36 AM, July 08, 2009  
Blogger Mads said...

I kept the launcher and it launches this new "main"-VI in the right context, so QuickDrop still works. I just think it's cooler when it all stays in the background.

As long as there is no need for multiple instances of the core and each of the handlers, the modularization is still there, even though some calls have been made static.

A transition to a plugin architecture would be suitable and simple yes - the cases in the command handler could be replaced with a dynamic call and the dictionary could be based on the names of the available plugins (perhaps with an alias option):-)

9:58 AM, July 08, 2009  
Blogger Anon A. Mus said...

Watching the three videos got me more excited about programming in Labview. So far, I can get the Quick Edit to work. However, LVSpeak doesn't work with Quick Drop window. I open the Quick Drop window but keeping the ctrl key pressed or releasing then pressing (and holding) the ctrl key again doesn't result in the command (such as "while loop") from appearing. I've made sure that "load palettes at launch" is checked. I'm using XP SP3 and LV 8.6. Am I missing something else?

Thanks for this great tool!

12:16 PM, July 09, 2009  
Blogger Norm Kirchner ~,~ said...

Anon, (clever)

So far I've heard a few reports of the Quick Drop not working.

Just to make sure, you've installed both OGP packages, correct?

If that's not the problem, I'll have you send me a specific file from your system to ensure that it was installed correctly.

12:35 PM, July 09, 2009  
Blogger Norm Kirchner ~,~ said...

And just a follow up to Anon's post wrt the Ctl Key.

For QuickDrop, after you press Ctl+Space to bring up the QD window, you can just simply keep the Ctl key held down until you see your speech detected in the QD window or LVSpeak floater window.

12:45 PM, July 09, 2009  
Blogger Anon A. Mus said...

Hello Norm! I checked my VI Package Manager and both both packages have the LabVIEW logo next to them. Is it a safe assumption that this means a valid installation for LVSpeak? Otherwise, let me know what file you would like me to send.

Thanks for your help!

2:38 PM, July 09, 2009  
Anonymous Matt Holt said...

Norm:

Any chance you've devoted any time at NIWeek to present this?

I think the idea is growing on me... Imagine me walking by one of the other coders desks and saying "You need to clean up your diagram" and LVSpeak picking up the "Clean Up Diagram" ... BAM, cleaner code.

You could always add more Vista and have it ask if your sure every time you tell it a command :)

1:16 PM, July 10, 2009  
Blogger Brian said...

Norm,

I have a discussion going on here on how these packages should be installed in the first place. Can you explain to me how this is done?

1:04 PM, July 30, 2009  
Blogger Norm Kirchner ~,~ said...

Sorry all about being an absentee blogger.

Anon, and others that seemingly have installed the Quick Drop LVS add-on but can not get it to work, zip up your

C:\Program Files\National Instruments\LabVIEW 8.6\resource\dialog\QuickDrop

Directory and send it to NJKirchner@gmail.com

Hopefully I'll be able to quickly figure out why you're able to command quick edit, but not the quick drop window.

Matt,
I don't know how much demo time LVSpeak is going to get at NI Week, but just look for the guy walking around with a headset on and ask for one (that'll be me)

7:57 AM, July 31, 2009  
Blogger Norm Kirchner ~,~ said...

Brian

Step 1 and 2 for getting the packages installed are

Install the VI Package Manager from www.jkisoft.com and configure it to link to your instance of LV 8.6

Install the Microsoft Speech SDK that is linked to in this post

Once both of those are done, installing the packages should be as simple as double clicking their icon in an explorer window. This should launch the VIPackage Manager and start the installation process for them.

What is the experience you're getting?

8:01 AM, July 31, 2009  
Blogger Brian said...

Norm,

The problem was that the packages are downloaded with a *.zip extension. All I had to do was rename them with the *.ogp extension and everything works fine. I've installed this on my machine with LV 8.6.1 and it all seems to work during a quick check. I tried to do the same on my home computer with XP home and LV 8.6. The install went well but when I tried to enable LV Speak in the tools menu labview crashed and was removed from memory completely.
Is this a known issue and do I need LV 8.6.1 instead of 8.6?

12:13 PM, August 01, 2009  
Blogger Norm Kirchner ~,~ said...

To all who contributed here,

Today I will be holding an independent (non-ni) webinar showcasing all the changes in LVSpeak.

I would really appreciate if you peel off a half hour to attend and give some feedback.

http://lavag.org/topic/9797-lvspeak-tell-lv-what-to-do/page__view__findpost__p__68642

There have been significant changes and additions that are worth checking out.

11:49 AM, November 11, 2009  

Post a Comment

<< Home