{"slug": "talking-to-my-terminal-with-local-speech-to-text-and-pi-coding-agent", "title": "Talking to My Terminal with Local Speech-to-Text and Pi Coding Agent", "summary": "A developer created two terminal commands that accept voice input for generating shell commands and answering questions using local speech-to-text and the Pi coding agent. The setup uses the hns CLI tool for on-device transcription and can work with local or remote LLMs, enabling hands-free interaction with the terminal.", "body_md": "I set up two terminal commands I can talk to, `,`\n\nand `q`\n\n. I enter `,`\n\nin terminal, hit Enter, say what I want, it gives me back the shell command. With `q`\n\ncommand, I ask a question out loud, and an LLM answers it (and can read files on disk to do so).\n\nThis 30 seconds demo shows what it looks like in practice:\n\nI saw this post by [Python Monty](https://z3ugma.github.io/2026/05/25/a-comma-and-a-question-mark/) about wiring up these two terminal commands:\n\n`, <description>`\n\nto get a shell command based on your description`q <question>`\n\nto have an LLM answer your question\n\nThis setup uses the Pi coding agent under the hood. After configuring these commands, we can do things like the following:\n\n```\n, find the 5 largest files in the current directory\n\nq read run-qwen36-q8.sh and summarize what it does in 3 bullet points\n```\n\nI immediately found this useful for quick shell commands and questions cause I didn't have to launch a full coding-agent session in Pi or Claude or open a web UI.\n\nNow, I'm a big fan of speech-to-text and I use voice typing for all my interactions with LLMs and coding agents. I have built this [hns CLI tool](https://github.com/primaprashant/hns) for speech-to-text in the terminal. `hns`\n\nwrites the transcription to stdout so it integrates well with other CLI tools.\n\nSo, of course, I wanted to adapt the workflow suggested by Python Monty so that I don't have to type anything after entering `,`\n\nor `q`\n\n. Instead, I can just speak out loud my request or question.\n\nThe transcription part of this setup runs locally on your machine. You can use local LLMs with Pi to keep the end-to-end setup on-device, or you can use remote LLMs.\n\n## Setting It Up on macOS\n\n### 1. Install hns\n\nInstall hns by running `uv tool install hns`\n\n. By default, `hns`\n\nuses the [base whisper](https://huggingface.co/Systran/faster-whisper-base) model, about 145 MB in size, which is good enough for this kind of use case. So you don't need to do any other setup for `hns`\n\n. During the first transcription, `hns`\n\nautomatically downloads the base model from Hugging Face. After that, transcription happens locally on your machine.\n\n### 2. Install and Configure Pi\n\nInstall Pi coding agent by following the [quickstart guide](https://pi.dev/docs/latest/quickstart), then configure a provider and model. You can [use a local LLM with Pi](https://huggingface.co/docs/hub/en/agents-local) to keep your entire setup on-device. Or you can set up cloud LLM through a ChatGPT or GitHub Copilot subscription, or an API key.\n\n### 3. Configure Comma Command\n\nThe `,`\n\ncommand helps you get a shell command for your use case. After setting this up, you just need to type `,`\n\nin the terminal, hit Enter, and start saying what you want the command to do in plain English.\n\nHit Enter again after you're done speaking and you'll soon see your request and then the shell command in your terminal. The shell command is also copied to the clipboard automatically, so you just need to press `Cmd+V`\n\nand hit Enter to execute the command.\n\nIf you're using `bash`\n\nor `zsh`\n\n, add this to your `~/.bashrc`\n\nor `~/.zshrc`\n\nfile:\n\n```\n,() {\n    local prompt command\n    prompt=$(hns)\n    printf '%s\\n' \"$prompt\"\n\n    command=$(pi --print --no-tools --thinking off \\\n        --system-prompt \"Output exactly one shell command,\n        the best one, with no numbering, no explanation,\n        no markdown, and no backticks. Output only the raw command\n        on a single line.\" \"$prompt\" 2>/dev/null)\n\n    printf '%s' \"$command\" | pbcopy\n    printf '%s\\n' \"$command\"\n}\n```\n\nIf you're using `fish`\n\n, add this to `~/.config/fish/config.fish`\n\nfile:\n\n```\nfunction ,\n    set -l prompt (hns | string collect)\n    printf '%s\\n' $prompt\n\n    set -l command (pi --print --no-tools --thinking off \\\n        --system-prompt \"Output exactly one shell command,\n        the best one, with no numbering, no explanation,\n        no markdown, and no backticks. Output only the raw command\n        on a single line.\" $prompt 2>/dev/null | string collect)\n\n    printf '%s' $command | pbcopy\n    printf '%s\\n' $command\nend\n```\n\nRestart your terminal or source the config file, and the `,`\n\ncommand should be available in your shell.\n\n### 4. Configure Question Command\n\nThe `q`\n\ncommand helps you get quick answers. I give Pi access to the read, grep, find, and ls tools for this command, so the model can answer questions based on existing knowledge or by reading and searching files on disk. Pi doesn't have a built-in `web_search`\n\ntool but you can configure a web-search tool yourself and make this command more capable.\n\nAfter setting up this command, you can type `q`\n\nin the terminal, hit Enter, and then say your question aloud in plain English. Hit Enter again after you're done speaking and you'll soon see your question followed by the answer in your terminal.\n\nIf you're using `bash`\n\nor `zsh`\n\n, add this to your `~/.bashrc`\n\nor `~/.zshrc`\n\nfile:\n\n```\nq() {\n    local prompt\n    prompt=$(hns)\n    printf '%s\\n' \"$prompt\"\n\n    pi --print \\\n        --system-prompt \"You are a helpful, concise assistant\n        running in a macOS terminal. Answer clearly and accurately.\n        You can read files from disk.\n        Use this ability for file-specific information.\" \\\n        --tools \"read,grep,find,ls\" \\\n        \"$prompt\"\n}\n```\n\nIf you're using `fish`\n\n, add this to `~/.config/fish/config.fish`\n\nfile:\n\n```\nfunction q\n    set -l prompt (hns | string collect)\n    printf '%s\\n' $prompt\n\n    pi --print \\\n        --system-prompt \"You are a helpful, concise assistant\n        running in a macOS terminal. Answer clearly and accurately.\n        You can read files from disk.\n        Use this ability for file-specific information.\" \\\n        --tools \"read,grep,find,ls\" \\\n        $prompt\nend\n```\n\nRestart your terminal or source the config file, and the `q`\n\ncommand should be available in your shell.\n\nIf this was useful, and you want workflows like these in your inbox, subscribe below. Thanks!", "url": "https://wpnews.pro/news/talking-to-my-terminal-with-local-speech-to-text-and-pi-coding-agent", "canonical_source": "https://www.agenticcodingweekly.com/p/talking-to-my-terminal-with-local-speech-to-text-and-pi-coding-agent", "published_at": "2026-06-20 12:03:11+00:00", "updated_at": "2026-06-20 12:37:37.428290+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "large-language-models", "ai-agents"], "entities": ["Pi", "hns", "Python Monty", "Hugging Face", "Whisper", "ChatGPT", "GitHub Copilot", "Claude"], "alternates": {"html": "https://wpnews.pro/news/talking-to-my-terminal-with-local-speech-to-text-and-pi-coding-agent", "markdown": "https://wpnews.pro/news/talking-to-my-terminal-with-local-speech-to-text-and-pi-coding-agent.md", "text": "https://wpnews.pro/news/talking-to-my-terminal-with-local-speech-to-text-and-pi-coding-agent.txt", "jsonld": "https://wpnews.pro/news/talking-to-my-terminal-with-local-speech-to-text-and-pi-coding-agent.jsonld"}}