From 36910d32746d294564ad08aa2a10783b8785ae9b Mon Sep 17 00:00:00 2001 From: Lucas Proxmox Date: Wed, 7 Oct 2026 14:32:29 +0200 Subject: [PATCH] feat(voice): /devscope:voice model chooses the server's voice (0.27.0) `model` lists the server's voices (/api/ai/voice-models, default first), `model ` stores the choice in voice.json and sends it as `model` with every voice-audio request, `model default` clears it. The homelab offers Chatterbox Turbo (new default, Arc B580) and Kokoro (previous voice, CPU, also the server's fallback). A name the server does not offer is refused. Co-Authored-By: Claude Opus 5.5 (1M context) --- .claude-plugin/marketplace.json | 2 +- .claude-plugin/plugin.json | 2 +- CHANGELOG.md | 12 +++++++++++ CLAUDE.md | 6 ++++-- README.md | 2 +- commands/voice.md | 4 ++-- scripts/voice/cli.sh | 36 ++++++++++++++++++++++++++++++--- scripts/voice/lib.sh | 6 +++++- tests/voice/run.sh | 10 +++++++++ 9 files changed, 69 insertions(+), 11 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index f155f8d..052f65d 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -10,7 +10,7 @@ { "name": "devscope", "description": "Real-time developer activity monitoring for Claude Code sessions", - "version": "0.26.0", + "version": "0.27.0", "author": { "name": "Lucas Dow", "email": "lucdow7@gmail.com" diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 03b172b..25fa7a3 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "devscope", - "version": "0.26.0", + "version": "0.27.0", "description": "Real-time developer activity monitoring for Claude Code sessions", "author": { "name": "Lucas Dow", diff --git a/CHANGELOG.md b/CHANGELOG.md index bfd7f9d..f903fe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## [0.27.0] - 2026-10-07 + +### Added +- **`/devscope:voice model [name|default]`** chooses which of the server's + voices speaks. Without a name it lists them (`/api/ai/voice-models`, the + first is the server's default); the choice is sent with every request as + `model`, and `model default` goes back to the server's choice. The homelab + now offers Chatterbox Turbo (the new default, on its Arc B580) and Kokoro + (the previous voice, on its CPU, also the server's fallback when the GPU is + busy). Needs a DevScope server with named voices (DowLucas/devscope); an + older one ignores the choice. + ## [0.26.0] - 2026-10-07 ### Added diff --git a/CLAUDE.md b/CLAUDE.md index d81ab58..ec84cb9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -210,8 +210,10 @@ claude plugin disable devscope@devscope # Disable still there, the timer takes the global speak lock and speaks every due marker: an AI sentence from `/api/ai/voice-summary`, or a local template for `private` sessions or when the backend fails; three or more due within 15 s become one sentence. Speech uses the - server voice by default (`/api/ai/voice-audio`, Kokoro on the homelab; `voice`/`speed` in - voice.json, default `am_michael`; `speed` 1.2× by default, presets slow 1.0 / normal 1.2 / fast 1.5, + server voice by default (`/api/ai/voice-audio`; the server picks among its named voices: on the + homelab Chatterbox Turbo on the B580, with Kokoro as fallback; voice.json `model` asks for one by name + via `/devscope:voice model`, sent as `model`, omitted for the server's default; `voice` is a Kokoro + voice name, default `am_michael`; `speed` 1.2× by default, presets slow 1.0 / normal 1.2 / fast 1.5, or any number 0.5-2, via `/devscope:voice speed`, applied to every engine), never for `private` sessions; if the server has no voice or is unreachable it falls back to Piper if installed (`/devscope:voice setup`), else `say`/`spd-say`/`espeak`. What is sent follows the diff --git a/README.md b/README.md index 80dfd5a..d2d4bf1 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ Running several sessions, or working in another window? `/devscope:voice on` mak - **Only when you've lost track.** It speaks after a grace delay (30 s for permission prompts and questions, 10 s for failed turns). Answer in time and it stays silent. If you don't, it reminds you every 5 minutes, up to 3 times. - **Across all sessions.** Announcements play one at a time, and three or more at once become one sentence ("three sessions need you: ..."). - **Summaries follow your privacy mode.** Sentences are written by DevScope's AI from what your privacy mode already sends. `private` sessions never leave your machine and use a local template. -- **Natural voice, nothing to install.** Announcements are voiced by your DevScope server (Kokoro, default voice `am_michael` at 1.2×; change `voice`/`volume` in `voice.json`, speed with `/devscope:voice speed`). `private` sessions, and any time the server can't be reached, use a local voice instead: [Piper](https://github.com/rhasspy/piper) if you ran `/devscope:voice setup` (Linux; `pipx install piper-tts` on macOS), otherwise the system voice (`say`, `spd-say`, `espeak`). +- **Natural voice, nothing to install.** Speech is voiced by your DevScope server. Which voices it offers is up to the server; the homelab offers **Chatterbox Turbo** (the default, on its GPU) and **Kokoro** (on its CPU, also the fallback when the GPU is busy). `/devscope:voice model` lists them, `/devscope:voice model kokoro` picks one for you, `model default` goes back to the server's choice. Speed with `/devscope:voice speed`, volume with `volume` in `voice.json`. `private` sessions, and any time the server can't be reached, use a local voice instead: [Piper](https://github.com/rhasspy/piper) if you ran `/devscope:voice setup` (Linux; `pipx install piper-tts` on macOS), otherwise the system voice (`say`, `spd-say`, `espeak`). Other commands: `off`, `mute 1h`, `unmute`, `test`, `status`, `finished on` (also announce finished turns after 2 min), `speed slow|normal|fast` (1.0×, 1.2× or 1.5×, for every voice; or any number from 0.5 to 2, e.g. `speed 1.35`), `stop` (end speech in progress). Settings live in `~/.config/devscope/voice.json`. diff --git a/commands/voice.md b/commands/voice.md index 628452a..29fe674 100644 --- a/commands/voice.md +++ b/commands/voice.md @@ -1,7 +1,7 @@ --- allowed-tools: Read, Grep, Glob, Bash(git diff:*), Bash(git status:*), Bash(git log:*), Bash(bash:*) description: DevScope voice: explain a topic out loud, auto voice after every reply, announcements when a session waits on you (explain, auto, verbosity, speed, on, off, mute, stop, test, setup) -argument-hint: "[explain [--short|--long] |auto [on|off]|verbosity [explain|auto] [short|normal|long]|when-locked [quiet|play]|speed [slow|normal|fast|1.35]|status|on|off|mute 1h|unmute|stop|test|setup|finished on|off]" +argument-hint: "[explain [--short|--long] |model [chatterbox|kokoro|default]|auto [on|off]|verbosity [explain|auto] [short|normal|long]|when-locked [quiet|play]|speed [slow|normal|fast|1.35]|status|on|off|mute 1h|unmute|stop|test|setup|finished on|off]" --- ## Your task @@ -18,7 +18,7 @@ bash "${CLAUDE_PLUGIN_ROOT}/scripts/voice/cli.sh" $ARGUMENTS Show the output to the user in a few short lines. Do not run anything else. -The default engine is `server`: the DevScope server voices speech (Kokoro, `voice` in voice.json, default `am_michael`). If the engine is `system` or `none`, mention that it needs a DevScope API key (`/devscope:setup`), and that `/devscope:voice setup` installs Piper as an offline fallback (Linux; on macOS use `pipx install piper-tts`). +The default engine is `server`: the DevScope server voices speech. `model` lists the server's voices (on the homelab: chatterbox, the default, and kokoro), `model ` picks one, `model default` goes back to the server's choice; when the chosen voice is busy or down, the server uses its next one. If the engine is `system` or `none`, mention that it needs a DevScope API key (`/devscope:setup`), and that `/devscope:voice setup` installs Piper as an offline fallback (Linux; on macOS use `pipx install piper-tts`). Three features: - **Explain** (`explain [topic]`): see *Explain mode* below. diff --git a/scripts/voice/cli.sh b/scripts/voice/cli.sh index 9f72ad4..67c6cf6 100755 --- a/scripts/voice/cli.sh +++ b/scripts/voice/cli.sh @@ -2,7 +2,7 @@ # /devscope:voice — turn the voice announcer and auto voice (a spoken summary of every reply) on/off, # mute, test, stop speech, install the Piper voice; `say` speaks text from # stdin (/devscope:voice explain). -# Usage: cli.sh [status|on|off|mute <30s|15m|1h>|unmute|test|setup|finished on|off|auto [on|off]|speed [slow|normal|fast|<0.5-2>]|verbosity [explain|auto] [short|normal|long]|when-locked [quiet|play]|stop|say] +# Usage: cli.sh [status|on|off|mute <30s|15m|1h>|unmute|test|setup|finished on|off|auto [on|off]|speed [slow|normal|fast|<0.5-2>]|verbosity [explain|auto] [short|normal|long]|when-locked [quiet|play]|model [name|default]|stop|say] set -uo pipefail VOICE_DIR="$(cd "$(dirname "$0")" && pwd)" # shellcheck disable=SC1091 @@ -18,7 +18,7 @@ status() { echo "Voice announcer: $(_ds_voice_enabled && echo on || echo off)" echo "Engine: $(_ds_voice_engine) (setting: $(_ds_voice_conf .engine auto))" [ "$(_ds_voice_engine)" = "server" ] && \ - echo "Server voice: $(_ds_voice_conf .voice "$DS_VOICE_SERVER_VOICE") via $DEVSCOPE_URL (private sessions and outages use a local voice)" + echo "Server voice: $(_ds_voice_conf .model "server default") via $DEVSCOPE_URL (private sessions and outages use a local voice)" echo "Speed: $(_ds_voice_speed_text)" echo "Delays: permission $(_ds_voice_delay permission)s, question $(_ds_voice_delay question)s," \ "failed $(_ds_voice_delay failed)s, finished $(_ds_voice_delay finished)s" \ @@ -62,6 +62,35 @@ auto() { esac } +# Which of the server's voices speaks: model [name|default]. No name lists them. +model() { + local name="${1:-}" offered + offered=$(_ds_api GET /api/ai/voice-models "" 5 2>/dev/null | jq -r '.models // [] | join(" ")' 2>/dev/null) + if [ -z "$name" ]; then + echo "Server voice: $(_ds_voice_conf .model "server default")" + if [ -n "$offered" ]; then + echo "This server offers: $offered (the first is its default)" + else + echo "Could not list the server's voices; run '/devscope:setup' if the API key is missing." + fi + return 0 + fi + if [ "$name" = default ]; then + _ds_voice_set 'del(.model)' + echo "Server voice: server default${offered:+ (${offered%% *})}" + return 0 + fi + case "$name" in + *[!a-z0-9-]*) echo "Usage: model [name|default]"; return 1 ;; + esac + if [ -n "$offered" ] && ! printf ' %s ' "$offered" | grep -q " $name "; then + echo "This server has no voice named '$name'. It offers: $offered" + return 1 + fi + _ds_voice_set --arg m "$name" '.model = $m' + echo "Server voice: $name" +} + # What happens while the screen is locked: quiet (default) holds announcements # until unlock, skips auto voice and stops an explanation; play ignores the lock. when_locked() { @@ -213,6 +242,7 @@ case "${1:-status}" in speed) speed "${2:-}" ;; verbosity) verbosity "${2:-}" "${3:-}" ;; when-locked) when_locked "${2:-}" ;; + model) model "${2:-}" ;; say) say ;; stop) stop ;; test) @@ -221,6 +251,6 @@ case "${1:-status}" in "${DEVSCOPE_PRIVACY:-standard}" ;; setup) setup ;; *) - echo "Usage: /devscope:voice [status|on|off|mute <30s|15m|1h>|unmute|test|setup|finished on|off|auto [on|off]|speed [slow|normal|fast|<0.5-2>]|verbosity [explain|auto] [short|normal|long]|when-locked [quiet|play]|stop]" + echo "Usage: /devscope:voice [status|on|off|mute <30s|15m|1h>|unmute|test|setup|finished on|off|auto [on|off]|speed [slow|normal|fast|<0.5-2>]|verbosity [explain|auto] [short|normal|long]|when-locked [quiet|play]|model [name|default]|stop]" exit 1 ;; esac diff --git a/scripts/voice/lib.sh b/scripts/voice/lib.sh index 8307b17..52df8b6 100755 --- a/scripts/voice/lib.sh +++ b/scripts/voice/lib.sh @@ -617,10 +617,14 @@ _ds_voice_server_fetch() { # text privacy out-file [attempts] local body code cfg="" attempt=1 attempts="${4:-2}" [ "${2:-standard}" != "private" ] && [ -n "${DEVSCOPE_API_KEY:-}" ] || return 1 # volume is only sent when set, so the server's default applies otherwise. + # `model` picks the server's voice by name (/devscope:voice model); unset, the + # server's default. `voice` is a Kokoro voice name, ignored by other voices. body=$(jq -nc --arg t "$1" --arg v "$(_ds_voice_conf .voice "$DS_VOICE_SERVER_VOICE")" \ + --arg model "$(_ds_voice_conf .model "")" \ --argjson s "$(_ds_voice_speed)" \ --arg vol "$(_ds_voice_conf .volume "")" \ - '{text: $t, voice: $v, speed: $s} + (if $vol == "" then {} else {volume: ($vol | tonumber)} end)' 2>/dev/null) || return 1 + '{text: $t, voice: $v, speed: $s} + (if $vol == "" then {} else {volume: ($vol | tonumber)} end) + + (if $model == "" then {} else {model: $model} end)' 2>/dev/null) || return 1 cfg="header = \"x-api-key: ${DEVSCOPE_API_KEY}\"" while :; do code=$(printf '%s' "$cfg" | curl --config - -s -o "$3" -w '%{http_code} %{content_type}' \ diff --git a/tests/voice/run.sh b/tests/voice/run.sh index fd56dd5..7530f49 100644 --- a/tests/voice/run.sh +++ b/tests/voice/run.sh @@ -171,6 +171,10 @@ configure; respond "RIFFfake" "audio/wav"; reset_hits [ "$(last .path)" = "/api/ai/voice-audio" ] && [ "$(last .key)" = "test-key" ] && ok "server voice: calls voice-audio with the API key" || bad "server path" "$(last .)" [ "$(last .body.text)/$(last .body.voice)/$(last .body.speed)" = "cloud needs you/am_michael/1.2" ] && ok "server voice: default am_michael at 1.2x" || bad "server body" "$(last .body)" [ "$(last .body.volume)" = "null" ] && ok "server voice: volume left to the server by default" || bad "server volume default" "$(last .body)" +[ "$(last .body.model)" = "null" ] && ok "server voice: no model sent by default (server's default voice)" || bad "server model default" "$(last .body)" +configure '.model = "kokoro"'; server_speak standard >/dev/null +[ "$(last .body.model)" = "kokoro" ] && ok "server voice: the chosen model is sent" || bad "server model" "$(last .body)" +configure; respond "RIFFfake" "audio/wav" configure '.voice = "af_heart" | .speed = 1.2 | .volume = 2.5' server_speak standard >/dev/null; [ "$(last .body.voice)/$(last .body.speed)/$(last .body.volume)" = "af_heart/1.2/2.5" ] && ok "server voice: voice, speed and volume from voice.json" || bad "server config" "$(last .body)" configure; reset_hits @@ -297,6 +301,12 @@ reset; "$S/voice/cli.sh" when-locked play >/dev/null; touch "$LOCK" ( . "$S/_helpers.sh"; . "$S/voice/lib.sh"; _ds_voice_can_play ) && bad "quiet" "plays while locked" || ok "when-locked quiet: silent while locked" [[ "$("$S/voice/cli.sh" status)" == *"Screen: locked; when locked: quiet"* ]] && ok "status shows the screen and the setting" || bad "status screen" "$("$S/voice/cli.sh" status | grep Screen)" "$S/voice/cli.sh" when-locked loud >/dev/null && bad "bad when-locked" "accepted" || ok "when-locked rejects an unknown value" +respond '{"models": ["chatterbox", "kokoro"]}' +[[ "$("$S/voice/cli.sh" model)" == *"This server offers: chatterbox kokoro"* ]] && [ "$(last .path)" = /api/ai/voice-models ] && ok "model lists the server's voices" || bad "model list" "$("$S/voice/cli.sh" model)" +"$S/voice/cli.sh" model kokoro >/dev/null; [ "$(jq -r .model "$CONF")" = kokoro ] && ok "model kokoro is stored" || bad "model set" "$(cat "$CONF")" +"$S/voice/cli.sh" model piper >/dev/null && bad "unknown model" "accepted" || ok "model rejects a voice the server does not offer" +"$S/voice/cli.sh" model "../x" >/dev/null && bad "bad model" "accepted" || ok "model rejects a malformed name" +"$S/voice/cli.sh" model default >/dev/null; [ "$(jq -r '.model // "unset"' "$CONF")" = unset ] && ok "model default clears the choice" || bad "model default" "$(cat "$CONF")" rm -f "$LOCK" # 12. Auto voice: reply summaries, independent of the announcer, on every finished turn.