---
name: hermes-stt-setup
description: "Enable Speech-to-Text (STT) in Hermes Agent."
version: 1.0.0
author: Hermes Agent
license: MIT
platforms: [linux, macos, windows]
---
# Hermes STT Setup

This skill walks you through enabling Speech‑to‑Text (STT) so Hermes can transcribe voice messages from Telegram, Discord, etc.

## Prerequisites
- Hermes Agent installed (`hermes` command available).
- Basic familiarity with `hermes config`.

## Step‑by‑Step

1. **Check current STT configuration**
   ```bash
   hermes config
   ```
   Look for the `stt:` section.

2. **Enable STT**
   ```bash
   hermes config set stt.enabled true
   ```

3. **Choose a provider**
   - **Local (faster‑whisper)** – free, no API key
   - **Local Command** – custom wrapper script (set `HERMES_LOCAL_STT_COMMAND` env var)
   - **Groq** – needs `GROQ_API_KEY`
   - **OpenAI Whisper** – needs `VOICE_TOOLS_OPENAI_KEY`
   - **Mistral Voxtral** – needs `MISTRAL_API_KEY`

   Example for local (faster-whisper):
   ```bash
   hermes config set stt.provider local
   ```

   Example for local_command (custom wrapper):
   ```bash
   hermes config set stt.provider local_command
   # REQUIRED: set the command template via env var (config.yaml is NOT read for this)
   export HERMES_LOCAL_STT_COMMAND="/path/to/wrapper.sh {input_path} {model} {output_dir} {language}"
   ```

### Container / Immutable Venv Deployments

If the Hermes venv (`/opt/hermes/.venv`) is root-owned on a read-only/immutable filesystem (common in Docker/s6 deployments):
- The native `local` provider **cannot work** — it requires faster-whisper inside that venv
- You **cannot** `pip install` into it (no root, immutable FS)
- You **cannot** patch the launcher (`/opt/hermes/libexec/hermes`) to extend `HERMES_SITE` (outside write-safe root)

**Use `local_command` provider with a wrapper that sets `PYTHONPATH` to user site-packages** where faster-whisper is already installed (e.g., `/opt/data/home/.local/lib/python3.14/site-packages`). This is the only viable path in this environment.

1. Enable STT and set provider:
   ```bash
   hermes config set stt.enabled true
   hermes config set stt.provider local_command
   ```
2. Create wrapper at `/opt/data/stt-wrapper.sh` (see [Local Command Wrapper Template](references/local-command-wrapper.md)):
   ```bash
   #!/bin/bash
   INPUT_PATH="$1"
   MODEL="$2"
   OUTPUT_DIR="$3"
   LANGUAGE="$4"
   mkdir -p "$OUTPUT_DIR"
   export PYTHONPATH="/opt/data/home/.local/lib/python3.14/site-packages:${PYTHONPATH:-}"
   python3 -c "
   import sys, os
   sys.path.insert(0, '/opt/data/home/.local/lib/python3.14/site-packages')
   from faster_whisper import WhisperModel
   model = WhisperModel('$MODEL', device='cpu', compute_type='int8')
   segments, info = model.transcribe('$INPUT_PATH', language='$LANGUAGE' if '$LANGUAGE' != 'auto' else None)
   text = ' '.join([seg.text for seg in segments]).strip()
   with open('$OUTPUT_DIR/transcript.txt', 'w') as f:
       f.write(text)
   print(text)
   "
   ```
3. Make executable: `chmod +x /opt/data/stt-wrapper.sh`
4. Restart gateway: `s6-svc -t /run/service/gateway-default` (or `/command/s6-svc -t ...`)

4. **Install the Whisper backend**
   - **Local faster‑whisper** (recommended)
     ```bash
     # If you have write access to the Hermes venv:
     uv pip install faster-whisper
     # If you need sudo:
     sudo uv pip install faster-whisper
     # Or install into a separate venv and point Hermes at it:
     uv venv ~/whisper_venv
     source ~/whisper_venv/bin/activate
     uv pip install faster-whisper
     # Then set VIRTUAL_ENV or adjust hermes' python path accordingly.
     ```

   **Important**: The Hermes venv at `/opt/hermes/.venv` is typically owned by root in container deployments. Installing packages requires root (sudo) or changing ownership. Without root access, prefer the `local_command` provider with a wrapper that uses a Python environment where faster-whisper is already installed (e.g., user site-packages at `/opt/data/home/.local/lib/python3.14/site-packages`).
   - **Provider‑specific** – just export the env var (no extra pip package needed).
   - **local_command** – write a wrapper script that receives `{input_path} {model} {output_dir} {language}` and writes transcript to `{output_dir}/transcript.txt`. The `HERMES_LOCAL_STT_COMMAND` env var **must** be set in the process environment (e.g. in the gateway service run script or `.env`); `stt.local_command` in config.yaml is ignored.

   **For s6/container deployments**: The env var must be present in the supervised gateway process environment. Set it in `/run/s6/container_environment/HERMES_LOCAL_STT_COMMAND` (requires root) or in the service's env directory (e.g. `/run/service/gateway-default/env/HERMES_LOCAL_STT_COMMAND`) and ensure the service run script sources these env vars. See [Local Command Wrapper Template](references/local-command-wrapper.md) for details.

  The gateway run script at `/run/service/gateway-default/run` must explicitly source env files from `/run/service/gateway-default/env/` — the `with-contenv` shebang only reads `/run/s6/container_environment/`. The default Hermes run script includes this sourcing loop.

   **Important**: Hermes's `_prepare_local_audio` converts the original audio (e.g., .ogg from Telegram) to a 16kHz mono WAV file in a temp directory before calling the wrapper. The wrapper receives this WAV file as `input_path`, not the original .ogg.

5. **Restart Hermes**
   - CLI: exit and relaunch `hermes`, or use `/reset` in chat.
   - Gateway: send `/restart` in the chat or run `hermes gateway restart`.

6. **Test**
   Send a voice message in your configured platform; Hermes should reply with the transcription.

## Troubleshooting

- **Permission denied on venv**
  The Hermes venv (`/opt/hermes/.venv`) is often owned by root. Either:
  - Use `sudo uv pip install faster-whisper`, or
  - Change ownership: `sudo chown -R $(whoami):$(whoami) /opt/hermes/.venv` (if allowed), then install.

- **ModuleNotFoundError after install**
  Ensure you are installing into the same Python environment that Hermes uses.
  Check with `which hermes` and `hermes --version` to locate the venv, then activate it before pip install.

- **Hermes launcher controls Python path**
  The Hermes launcher at `/opt/hermes/libexec/hermes` sets `HERMES_SITE` to only the venv site-packages (`$root/.venv/lib/python3.14/site-packages`). This means user-site packages (e.g., `/opt/data/home/.local/lib/python3.14/site-packages`) are NOT visible to the `local` provider. To use the native `local` provider with user-installed faster-whisper, you must either:
  1. Install faster-whisper into the Hermes venv (requires root/sudo)
  2. Patch the launcher to extend `HERMES_SITE` with the user site-packages path
  3. Use the `local_command` provider with a wrapper that explicitly sets `PYTHONPATH` to include user site-packages

- **faster-whisper fails with PyAV 19.x** (`TypeError: open() got an unexpected keyword argument 'metadata_errors'`)
  `faster-whisper` 1.2.1 is incompatible with PyAV >= 19. Downgrade PyAV:
  ```bash
  pip install 'av<19'
  ```
  This installs PyAV 18.1.0 which works. Verify with `python -c "import av; print(av.__version__)"`.

- **No transcription**
  Verify `stt.enabled` is `true` and the provider matches the installed backend.
  Check Hermes logs: `~/.hermes/logs/gateway.log` for errors.

- **local_command provider configured but transcription fails**
  The `stt.local_command` section in config.yaml is **not read** by Hermes. You **must** set the `HERMES_LOCAL_STT_COMMAND` environment variable in the process that runs the gateway (e.g. in the s6 service run script, docker env, or `.env`). The template receives `{input_path} {model} {output_dir} {language}` and must write the transcript to `{output_dir}/transcript.txt`.

  **For s6/container deployments**: If the gateway runs under s6 (e.g. Docker), the env var must be present in the supervised process environment. Set it in `/run/s6/container_environment/HERMES_LOCAL_STT_COMMAND` or in the service's env directory (e.g. `/run/service/gateway-default/env/HERMES_LOCAL_STT_COMMAND`), and ensure the service run script sources these env vars (e.g. with a loop over `/run/service/gateway-default/env/*`).

- **Transcription works but transcript is echoed before the reply**
  Set `stt.echo_transcripts: false` in config.yaml (or `hermes config set stt.echo_transcripts false`) to disable the "🎙️ Transcript: ..." message that appears before the actual agent reply.

- **local_command provider configured but transcription fails with empty input_file**
  The wrapper receives `input_file=''` (empty string) to ffmpeg. This typically means `_prepare_local_audio` returned an empty path. Check:
  1. The `HERMES_LOCAL_STT_COMMAND` env var is actually set in the gateway process environment (verify with `cat /proc/$(pgrep -f "gateway run")/environ | tr '\0' '\n' | grep HERMES_LOCAL_STT_COMMAND`)
  2. The wrapper script is executable and in PATH
  3. ffmpeg is available in the gateway's PATH
  4. Add debug logging to the wrapper to see what arguments Hermes actually passes

- **Language code must be valid**
  The language argument passed to the wrapper must be a valid Whisper language code (ISO 639-1 like `de`, `en`, `fr`). Invalid codes (e.g., `test`) cause `ValueError: 'test' is not a valid language code`. Use `de` for German, leave empty for auto-detect.

- **Output directory must exist**
  The wrapper must ensure `output_dir` exists before writing `transcript.txt` (use `mkdir -p "$OUTPUT_DIR"`). Hermes creates this per-request but the wrapper should be defensive.

## Reference

- [Local Command Wrapper Template](references/local-command-wrapper.md) — wrapper script requirements, example, and s6/container deployment details
- Official docs: https://hermes-agent.nousresearch.com/docs/user-guide/features/voice/
---