Project 01 · SPOKEN
SPOKEN: voice coding in the browser
SPOKEN is voice coding in the browser. You speak a program in Vertex, an English-like programming language, and SPOKEN types it into a code editor and runs it in the page. Nothing to install, no account.
What SPOKEN is
SPOKEN pairs a small programming language with a dictation layer built for it. The language, Vertex, uses English words where most languages use symbols: make creates a variable, define creates a function, give returns a value, and each loops. The dictation layer turns speech into that code as you talk, including the parts that are hard to say, such as indentation, brackets, and operators.
Speech recognition comes from your browser's built-in Web Speech API, so the audio never touches a server run by this site. The editor is Monaco (the editor inside VS Code), and the Vertex interpreter is plain JavaScript running in the same page. Typing by hand always works too.
A worked example
Say these four phrases, pausing between them:
define double with put then
give put times two ok
print double five pair
run
SPOKEN writes this program and presses Run:
define double with put
give put * 2
print double(5)
The console prints 10. Here is what each spoken word did:
| You say | SPOKEN does |
|---|---|
then | Starts a new line one indent level deeper, opening a block |
times, two | Types * and the digit 2 |
ok | Starts a new line one indent level back out, closing the block |
double | Types double(, because double was defined as a function earlier |
pair | Closes the innermost open bracket |
run | Presses the Run button |
How voice coding works in SPOKEN
Most of a program is easy to dictate. The hard parts are structure and symbols, so SPOKEN gives each one a short spoken word that doesn't collide with Vertex's own keywords.
Indentation by voice
Vertex blocks are indented, like Python. Three words handle every line break: then opens a block, so continues at the same level, and ok closes a block. back deletes the last word, and line five moves the cursor to line 5.
Brackets without saying "open parenthesis"
par types (, index types [, and curl types {. A single closing word, pair, closes whichever bracket is innermost, so you never have to say which kind. SPOKEN also remembers your function names: say a function you defined and it opens the parenthesis for you.
Operators and numbers
Operators are words: plus, minus, times, divided by, mod, power, more, less, is, and not equals. Spoken numbers such as "twenty three" or "two thousand six" become digits. Text goes between quote and quote, and everything in between becomes one string, even words that are normally commands.
Fixing what speech recognition mishears
Browser speech recognition favors common English words, so SPOKEN corrects the collisions it knows about: "than" becomes then, "sew" becomes so, "pear" becomes pair, "knot" becomes not, and "eye" becomes the loop variable i. it types the last name you mentioned, which saves repeating long variable names.
One deliberate gap: par and pair sound alike in fast speech but are never cross-corrected, because one opens a bracket and the other closes it. Guessing wrong there would break the program silently.
Vertex, the English-like programming language
Vertex is designed to read like English and to be comfortable to say out loud. A few of its choices:
make total 0declares a variable.make a Dog as rex with "Husky"creates an object.withintroduces parameters for functions and classes:define add with a, b.asconverts types:take x as numberreads input as a number.each 3loops three times, and the loop variable is alwaysi(thenj, thenkfor nested loops), so there is nothing to name.mostlyasks a list a question:if votes mostly yesis true when more than half the list isyes.sayspeaks a value aloud with the browser's speech synthesis, andnotestarts a comment.
A complete program, with its output:
class Dog with breed
define speak
give "Woof from a " + self.breed
make a Dog as rex with "Husky"
print rex.speak()
Woof from a Husky
Why build a programming language for voice
SPOKEN is part of a longer project: expressing programming in natural language, so that code is easy both to read and to write. Dictation is a strict test of that goal. If a syntax makes you say "open paren" every few words, it isn't natural yet, and voice exposes that immediately in a way a keyboard hides.
Designing for speech has pushed Vertex toward fewer brackets, keyword-led blocks, and names that sound different from each other. Those changes make the written code easier to read too.
Browser support
Voice input needs a browser that supports speech recognition through the Web Speech API, such as Chrome, Edge, or Safari. Firefox doesn't support it by default, but typing and running code work in every modern browser. Your browser will ask for microphone permission the first time you tap the mic.
Frequently asked questions
- How do you code by voice?
- In SPOKEN you tap the mic and speak the program. Words like
then,okandpairact as commands for indentation and brackets, operators are spoken as words likeplusandtimes, and spoken numbers become digits. - Is SPOKEN free, and do I need to install anything?
- It is free and runs entirely in the browser. There is no install, signup or account.
- Does SPOKEN send my voice to a server?
- SPOKEN uses your browser's built-in speech recognition. This site runs no server of its own for audio, but some browsers send speech to their own recognition service, so check your browser's privacy policy if that matters to you.
- What programming language does SPOKEN use?
- It uses Vertex, an English-like language with keywords such as
make,define,give,eachandwith. It supports functions, classes with inheritance, lists, text methods, and error handling withtryandcatch. - Which browsers support voice input?
- Browsers with Web Speech API recognition, such as Chrome, Edge and Safari. In other browsers you can still type and run Vertex code.
- What if a variable name collides with a voice command?
- Words such as
run,lineandpairare reserved while dictating. Type that name by hand, or wrap it inquote…quote.