Speak a label to press what the canvas draws
A panel of switches drawn through a shader. Press "Listen" and say a name on the panel, such as "lamp" or "studio", or type the words in the box. The control is clicked, a ring spreads from it through the panel, and the transcript at the bottom highlights each word.
Say the name of a control
Show the code speech recognition biased to the controls on the panel
- A panel of buttons with one attribute.
fx="voice"draws it through the shader. The second set of switches ishidden. - The names of the controls that are drawn now.
- Start recognition with those names as phrases. On-device when
SpeechRecognition.available()says so. Phrases are rebuilt after a press, because the press may show other controls. - Match words to names and click.
poke()starts the ring where the control is. - The transcript and its highlights. One text node and two
Highlightobjects. - The CSS: two properties for the shader, two highlight styles.
- The shader. Waves scaled by the sound level, a ring from each press, a band of light while listening. GLSL and WGSL.
- The page script.
How it works
The panel is one drawable element, uploaded to a texture on every paint and drawn by a fragment shader
(fx: WebGPU when it works, else WebGL). The names of the buttons that aren't hidden are read
from the DOM and given to SpeechRecognition as phrases, which makes the recogniser favour them. Words that come back
are compared with the same names, and a match calls click() on the button. Switching room hides one set of buttons and shows
the other, so the phrase list and the names that can be pressed change with what is drawn.
Words reach the panel through one function. The microphone, the text box and the live checks all call it, so the panel, the ring and the transcript work in a browser with no speech recognition. The line under the demo says which parts of the Web Speech API this browser has.
Live checks
| Result | Experiment | Detail |
|---|
Findings
- The accessible names in the DOM are enough to drive a canvas UI by voice. The page doesn't keep a list of commands. It reads the names of the buttons that are drawn, and
click()doesn't depend on where the shader puts the pixels. - Custom highlights are in the element's picture. The live check compares the panel's texture with and without a highlight on one word of the transcript, and the pixels differ. The shader bends the highlighted word with the rest.
- A press from script can start the same ring as a pointer.
click()fires no pointer event, so the page calls the surface'spoke(x, y)with the control's layout position. - Speech recognition couldn't be run in the test browser. Headless Chromium 157 has
SpeechRecognition,phrases,available()andinstall(), and no microphone. Recognition, on-device processing and the effect of the phrase list aren't verified. SpeechRecognition.available({ langs: ['en-US'], processLocally: true })crashes the tab in headless Chromium 157. The page therefore asks only after a tap on "Listen" or on the live checks button, and the check refuses to ask in an automated browser. Whether Chrome on a phone has the same crash isn't known.SpeechRecognitionResultisn't a global in Chromium 157, so the timestamp check can't seespeechStartTimethere.- Timestamps are per result, not per word (from the feature's description; not run).
speechStartTimeandspeechEndTime(Chrome 159) are onSpeechRecognitionResult. The page spreads the words of a final result evenly between the two times. Before a result is final, each word has the time it arrived. "Replay the timing" plays the highlights back with those times. - Not verified: everything that needs a microphone, on-device recognition on Android, whether
phraseschanges what is recognised, and WebGPU on screen.