[Idle-dev] Making Python Speech-Friendly Under IDLE

Tim Peters tim.one@home.com
Wed, 6 Dec 2000 17:25:20 -0500


[JP S-C]
>      Is anyone interested in making Python's
> whitespace (tabs) more speech-friendly under IDLE?

[David Scherer]
> How would this be done?

I'm not clear on what JP has in mind either.

> I don't know anything about the conventions used for such things.
>
> if x<>y:
> 	if x<3:
> 		x = x + 1
> 	x = x + y
>
> Saying each tab character where it appears gives:
>
> "if x not equal y colon; tab if x less than 3 colon; tab tab x
> equals x plus 1; tab x equals x plus y"
>
> Saying the invisible DEDENT tokens gives:
> ...

Programming by speech is difficult, because variable and module names are
rarely chosen for ease of pronunciation (pyclbr.py), many aren't real words
at all (== they're unlikely to be found in a recognition engine's database
of word pronunciations), and there's a weak "language model" (only part of
speech recog is acoustic recognition; the rest has to make sense of context,
as in "Please write a letter to Mrs. Wright right away, please":  there are
3 homonyms of "write" in that sentence, and only context can determine which
was intended in each place).  So it's a tough problem, and block structure
seems the least of it.

Suggest

   if x not equal y open-block
   if x less than 3 open-block
   x equals x plus 1 close-block  # how to know "one" wasn't intended?
   x equals x plus y close-block  # how to know "why" wasn't intended?

The phrases "open-block" and "close-block" are not confusable via acoustics
(they're better this way than, say, "indent" and "dedent"), and could be
treated like keystroke macros (open-block -> colon then newline (IDLE will
indent by itself given those keys); close-block -> newline then backspace,
although IDLE will invent the backspace by itself sometimes (e.g., after a
"return" stmt), so the IDLE parser should communicate with the speech module
to do what's intended rather than what's said <wink>).

> ...
> How about using pitch?

A few years ago, a blind fellow on comp.lang.python reported using pitch in
a text-to-speech add-on to the Emacs python-mode, to help him understand
when indentation changed in Python code.  It's important to remember that
people are very good at mining info out of *any* system of clues, no matter
how odd they may seem at first, provided they're consistent.  I've heard
that some people can even make sense out of Perl code <wink>.