Lets dictate

Why should one bother with writing text manually when you can just dictate stuff?

Kalle Tolonen
Sept. 7, 2026
Last updated on Sept. 8, 2026

Mobile kind of writing has never been my strong suit so I implemented a dictation js in locally run inference for the phone.

Seems to work kind of okay.

We did a small refactoring with the addition of a redo button. Also the sentences end easily when you stop speaking.

Key logic described here:

// voice-dictate.js — core logic

on Dictate click:
  start SpeechRecognition (continuous, interimResults)
  session = { pendingText, baseLength, committedByIndex }
  history = editor._ktcomDictateHistory  // completedBits[] for redo

on each FINAL speech result:
  cleaned = strip fillers + normalize whitespace
  if already seen at this index → skip

  if pendingText exists and new text is NOT a cumulative extension:
    commit pending utterance
      → capitalize, add punctuation
      → push { start, end } to completedBits
      → advance baseLength

  else if no pendingText yet:
    baseLength = editor.value.length   // mark where this phrase starts

  pendingText = cleaned
  replace editor text in place:
    editor.value = editor.value[0:baseLength] + formatted chunk
    // capitalize now; punctuation only on commit

on Stop / recognition end:
  commit any remaining pendingText

on Redo click:
  pop last completedBits entry
  remove editor.value[start:end]

And the key reason for dictation isn't laziness but the ease of creating content. I think that the more you remove the barriers between creation and publishing the better.

And the 2nd pass for the iteration was just adding the dictation controls as floating elements.

As a final mobile ux-pass, I moved the photo insertion dialog to same element.

100% private, vanilla js, no 3rd party dependencues. What a glorious day!


Comments

No published comments yet.


Add a Comment

Your comment may be published.