I'm writing an emacs extension for use with speech recognition, and I'm looking for help with a particular feature. Some words the speech recognizer (Dragon) recognizes consistently poorly -- it doesn't matter how many times you train it, it will just suck at recognizing certain words. At the same time usually when you're writing on a topic or when coding you'll be using a lot of the same words over and over again.
So I've written a mode that uses overlays to change how words are rendered in the buffer. It takes a random letter in the word, underlines it in a random color, and puts a random diacritical mark (accent, umlaut, etc.) over the top of it. Here's a screenshot (you will probably need to zoom to see marks/underlines):
Then you can say, "purple p hair" and it will look for the word with a purple underline under its 'a' with a diacritical mark that looks like hair and type that word for you. So in the above screenshot saying that would cause emacs to type "regexp-quote" for you.
The idea is this lets you refer to any word you've already used that's onscreen using a finite set of words the recognizer is consistently good at recognizing.
It works pretty well, except occasionally there is a collision. To make it so I can learn to consistently refer to words the same way I'm using bytes from the md5 hash of the word instead of
(random) or having an algorithm assign the changes such that collisions are avoided. I've only found 6 easily distinguishable colors (it's hard when the underline is only one character wide and a single pixel thick) and 3 easily distinguishable diacritical marks (easy to tell apart from one another and also not confusable with an underline on the above line or overlapping with the underline), seen at the top of the source above.
I need more ways to alter rendering in order to reduce the collision frequency. Ideally a rendering modification would:
- Not be jarring from the rest of the text. This has lead me to dismiss for example the inverse-video property.
- Not be easily confusable with other changes. Overlines are easily mistaken for underlines on the previous line. Lots of diacritical marks look similar unless your font size is impractically huge.
- Be spatially near where the other changes are. Right now once my eye finds the targeting character all the information is there, the marker, the underline, and the letter.
- Work nicely with a fixed width font (needed for coding) that correctly renders diacritical marks (I had to switch to DejaVu Sans Mono from Consolas in order to have the marks render correctly)
- Work on latin alphabet letters. There are arabic combining marks for example, but they don't combine on latin alphabet characters.
- Not change letter color, since that's already being used for syntax highlighting.
- Actually be doable in emacs with emacs lisp ;)
Maybe there are special unicode characters controlling rendering that could be abused to open up new possibilities? Or a way to thicken underlines so I might be able to easily distinguish more colors? Or some other obscure emacs feature letting you render marks on top of characters besides unicode?