Back to DevLog

Making Foreman Voice Commands Interruptible and Speech-Friendly

1 min read

I ran Foreman in voice mode and found two things that made it hard to use. Long spoken replies locked me out until they finished, and the router was reading markdown formatting aloud.

Barge-In During Speech

I added a poll loop to say() that checks for ctrl+space or Esc every 50ms while audio plays. Ctrl+space stops playback and returns "interrupted" so the loop can immediately start recording. Esc stops playback and returns "exit" to unwind the voice loop. The keyboard library is imported lazily with a try/except so if it's missing, speech falls back to the blocking wait and still works.

Short Spoken Replies

The router was sending markdown-formatted text to TTS and a weather denial took 15 seconds to read. I wrote strip_for_speech() to remove asterisks, backticks, and bullet markers, turn each line into a sentence, and cap output at two sentences. The full reply still prints to the terminal. I also added an instruction to the router system prompt asking for replies in two plain sentences with no markdown.

Both fixes shipped in commit 563bca3. Live test passed: barge-in cut speech and started recording immediately, and the weather denial spoke as two plain sentences.

Share this post