Skip to content
Back to search

voicemode

Natural voice conversations with Claude Code

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026. Its scripts were only partly scanned.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/mbailey/voicemode with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/mbailey/voicemode'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/mbailey--voicemode/badge.svg)](/listings/mbailey--voicemode)

HTML

<a href="/listings/mbailey--voicemode"><img src="/api/listings/mbailey--voicemode/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

These steps run a script from the network that findsafeskills does not scan.

**Requirements:** Computer with microphone and speakers

Option 1: Claude Code Plugin (Recommended)

The fastest way for Claude Code users to get started:

# Add the VoiceMode marketplace
claude plugin marketplace add mbailey/voicemode

# Install VoiceMode plugin
claude plugin install voicemode@voicemode

## Install dependencies (CLI, Local Voice Services)

/voicemode:install

# Start talking!
/voicemode:converse

Option 2: Python installer package

Installs dependencies and the VoiceMode Python package.

# Install UV package manager (if needed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Run the installer (sets up dependencies and local voice services)
uvx voice-mode-install

# Add to Claude Code
claude mcp add --scope user voicemode -- uvx --refresh --from voice-mode voicemode-mcp-launcher

# Optional: Add OpenAI API key as fallback for local services
export OPENAI_API_KEY=your-openai-key

# Start a conversation
claude converse

For manual setup, see the [Getting Started Guide](docs/tutorials/getting-started.md).

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 38 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. {
  2. "name": "voicemode",
  3. "metadata": {
  4. "description": "VoiceMode - Voice conversations for Claude Code",
  5. "version": "1.1.0"
  6. },
  7. "owner": {
  8. "name": "VoiceMode",
  9. "email": "hello@voicemode.dev"
  10. },
  11. "plugins": [
  12. {
  13. "name": "voicemode",
  14. "description": "Voice conversations with Claude Code using local speech-to-text and text-to-speech. Includes support for remote agents via mobile, web and CLI.",
  15. "author": {
  16. "name": "Mike Bailey",
  17. "email": "mike@voicemode.dev"
  18. },
  19. "source": "./",
  20. "category": "productivity",
  21. "homepage": "https://github.com/mbailey/voicemode"
  22. },
  23. {
  24. "name": "show-me",
  25. "description": "Visual context sharing between AI and users - display files/URLs/commands with 'show', observe screen context with 'look'",
  26. "author": {
  27. "name": "Mike Bailey",
  28. "email": "mike@voicemode.dev"
  29. },
  30. "source": {
  31. "source": "url",
  32. "url": "https://github.com/mbailey/show-me.git"
  33. },
  34. "category": "productivity",
  35. "homepage": "https://github.com/mbailey/show-me"
  36. }
  37. ]
  38. }
README.md · README · 228 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # VoiceMode
  2. > Natural voice conversations with Claude Code (and other MCP capable agents)
  3. **New, 9 Nov 2026: [Session Kit](https://github.com/sessionkit/sessionkit)**,
  4. from the people who brought you VoiceMode. A voice, a phone line and mail for
  5. your Claude Code sessions. Works on macOS; preliminary testing on Linux.
  6. [![PyPI Downloads](https://static.pepy.tech/badge/voice-mode)](https://pepy.tech/project/voice-mode)
  7. [![PyPI Downloads](https://static.pepy.tech/badge/voice-mode/month)](https://pepy.tech/project/voice-mode)
  8. [![PyPI Downloads](https://static.pepy.tech/badge/voice-mode/week)](https://pepy.tech/project/voice-mode)
  9. VoiceMode enables natural voice conversations with Claude Code. Voice isn't about replacing typing - it's about being available when typing isn't.
  10. **Perfect for:**
  11. - Walking to your next meeting
  12. - Cooking while debugging
  13. - Giving your eyes a break after hours of screen time
  14. - Holding a coffee (or a dog)
  15. - Any moment when your hands or eyes are busy
  16. ## See It In Action
  17. [![VoiceMode Demo](https://img.youtube.com/vi/cYdwOD_-dQc/maxresdefault.jpg)](https://www.youtube.com/watch?v=cYdwOD_-dQc)
  18. ## Quick Start
  19. **Requirements:** Computer with microphone and speakers
  20. ### Option 1: Claude Code Plugin (Recommended)
  21. The fastest way for Claude Code users to get started:
  22. ```bash
  23. # Add the VoiceMode marketplace
  24. claude plugin marketplace add mbailey/voicemode
  25. # Install VoiceMode plugin
  26. claude plugin install voicemode@voicemode
  27. ## Install dependencies (CLI, Local Voice Services)
  28. /voicemode:install
  29. # Start talking!
  30. /voicemode:converse
  31. ```
  32. ### Option 2: Python installer package
  33. Installs dependencies and the VoiceMode Python package.
  34. ```bash
  35. # Install UV package manager (if needed)
  36. curl -LsSf https://astral.sh/uv/install.sh | sh
  37. # Run the installer (sets up dependencies and local voice services)
  38. uvx voice-mode-install
  39. # Add to Claude Code
  40. claude mcp add --scope user voicemode -- uvx --refresh --from voice-mode voicemode-mcp-launcher
  41. # Optional: Add OpenAI API key as fallback for local services
  42. export OPENAI_API_KEY=your-openai-key
  43. # Start a conversation
  44. claude converse
  45. ```
  46. For manual setup, see the [Getting Started Guide](docs/tutorials/getting-started.md).
  47. ## Features
  48. - **Natural conversations** - speak naturally, hear responses immediately
  49. - **Works offline** - optional local voice services (Whisper STT, Kokoro TTS)
  50. - **Low latency** - fast enough to feel like a real conversation
  51. - **Smart silence detection** - stops recording when you stop speaking
  52. - **Privacy options** - run entirely locally or use cloud services
  53. ## Compatibility
  54. **Platforms:** Linux, macOS, Windows (native or WSL), NixOS
  55. **Python:** 3.10-3.14
  56. ## Configuration
  57. VoiceMode works out of the box. For customization:
  58. ```bash
  59. # Set OpenAI API key (if using cloud services)
  60. export OPENAI_API_KEY="your-key"
  61. # Or configure via file
  62. voicemode config edit
  63. ```
  64. See the [Configuration Guide](docs/guides/configuration.md) for all options.
  65. ## Permissions Setup (Optional)
  66. To use VoiceMode without permission prompts, add to `~/.claude/settings.json`:
  67. ```json
  68. {
  69. "permissions": {
  70. "allow": [
  71. "mcp__voicemode__converse",
  72. "mcp__voicemode__service"
  73. ]
  74. }
  75. }
  76. ```
  77. See the [Permissions Guide](docs/guides/permissions.md) for more options.
  78. ## Local Voice Services
  79. For privacy or offline use, install local speech services:
  80. - **[Whisper.cpp](docs/guides/whisper-setup.md)** - Local speech-to-text
  81. - **[Kokoro](docs/guides/kokoro-setup.md)** - Local text-to-speech with multiple voices
  82. These provide the same API as OpenAI, so VoiceMode switches seamlessly between them.
  83. ## Installation Details
  84. <details>
  85. <summary><strong>System Dependencies by Platform</strong></summary>
  86. #### Ubuntu/Debian
  87. ```bash
  88. sudo apt update
  89. sudo apt install -y ffmpeg gcc libasound2-dev libasound2-plugins libportaudio2 portaudio19-dev pulseaudio pulseaudio-utils python3-dev
  90. ```
  91. **WSL2 users**: The pulseaudio packages above are required for microphone access.
  92. #### Fedora/RHEL
  93. ```bash
  94. sudo dnf install alsa-lib-devel ffmpeg gcc portaudio portaudio-devel python3-devel
  95. ```
  96. #### macOS
  97. ```bash
  98. brew install ffmpeg node portaudio
  99. ```
  100. #### NixOS
  101. ```bash
  102. # Use development shell
  103. nix develop github:mbailey/voicemode
  104. # Or install system-wide
  105. nix profile install github:mbailey/voicemode
  106. ```
  107. </details>
  108. <details>
  109. <summary><strong>Alternative Installation Methods</strong></summary>
  110. #### From source
  111. ```bash
  112. git clone https://github.com/mbailey/voicemode.git
  113. cd voicemode
  114. uv tool install -e .
  115. ```
  116. #### NixOS system-wide
  117. ```nix
  118. # In /etc/nixos/configuration.nix
  119. environment.systemPackages = [
  120. (builtins.getFlake "github:mbailey/voicemode").packages.${pkgs.system}.default
  121. ];
  122. ```
  123. </details>
  124. ## Troubleshooting
  125. | Problem | Solution |
  126. |---------|----------|
  127. | No microphone access | Check terminal/app permissions. WSL2 needs pulseaudio packages. |
  128. | UV not found | Run `curl -LsSf https://astral.sh/uv/install.sh \| sh` |
  129. | OpenAI API error | Verify `OPENAI_API_KEY` is set correctly |
  130. | No audio output | Check system audio settings and available devices |
  131. ### Save Audio for Debugging
  132. ```bash
  133. export VOICEMODE_SAVE_AUDIO=true
  134. # Files saved to ~/.voicemode/audio/YYYY/MM/
  135. ```
  136. ## Documentation
  137. - [Getting Started](docs/tutorials/getting-started.md) - Full setup guide
  138. - [Configuration](docs/guides/configuration.md) - All environment variables
  139. - [Whisper Setup](docs/guides/whisper-setup.md) - Local speech-to-text
  140. - [Kokoro Setup](docs/guides/kokoro-setup.md) - Local text-to-speech
  141. - [Development Setup](docs/tutorials/development-setup.md) - Contributing guide
  142. Full documentation: [voicemode.dev](https://voicemode.dev)
  143. ## Links
  144. - **Website**: [voicemode.dev](https://voicemode.dev)
  145. - **GitHub**: [github.com/mbailey/voicemode](https://github.com/mbailey/voicemode)
  146. - **PyPI**: [pypi.org/project/voice-mode](https://pypi.org/project/voice-mode/)
  147. - **YouTube**: [@getvoicemode](https://youtube.com/@getvoicemode)
  148. - **Twitter/X**: [@getvoicemode](https://twitter.com/getvoicemode)
  149. - **Newsletter**: [![Subscribe](https://img.shields.io/badge/Subscribe-Newsletter-orange?style=flat-square)](https://buttondown.com/voicemode)
  150. ## License
  151. MIT - A [Failmode](https://failmode.com) Project
  152. ---
  153. mcp-name: dev.voicemode/voicemode
docs/web/install.sh · Bundled script · 1,188 lines · 3 findings marked
  1. #!/usr/bin/env bash
  2. # VoiceMode Installer
  3. # https://getvoicemode.com/install.sh
  4. #
  5. # Usage:
  6. # curl -fsSL https://getvoicemode.com/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 6 on GitHub
  7. # curl -fsSL https://getvoicemode.com/install.sh | bash -s -- -y # non-interactive
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 7 on GitHub
  8. # curl -fsSL https://getvoicemode.com/install.sh | bash -s -- -y --voice mlx
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 8 on GitHub
  9. #
  10. # This script installs VoiceMode and its dependencies.
  11. # It supports macOS and Linux (Debian/Ubuntu, Fedora).
  12. #
  13. # Voice backend (--voice, or VOICEMODE_VOICE_ENGINE env):
  14. # mlx Apple Silicon only: mlx-audio (one fast on-device server for
  15. # STT+TTS). Recommended on Apple Silicon; opt-in.
  16. # local whisper.cpp + Kokoro (cross-platform; the only option off
  17. # Apple Silicon).
  18. # skip install no local voice services.
  19. # Default when unset: interactive prompt; non-interactive skips the large
  20. # local-voice download (unchanged prior behaviour).
  21. set -o nounset -o pipefail -o errexit
  22. # -----------------------------------------------------------------------------
  23. # Configuration
  24. # -----------------------------------------------------------------------------
  25. VOICEMODE_PACKAGE="voice-mode"
  26. INTERACTIVE=true
  27. # Voice backend selection (VM-1330).
  28. # "" - not explicitly chosen; resolved interactively or by the
  29. # non-interactive skip default (preserves prior behaviour).
  30. # mlx - Apple Silicon only: install mlx-audio (one fast on-device
  31. # server for STT+TTS) and point VoiceMode at it.
  32. # local - whisper.cpp + Kokoro (the cross-platform path; the only
  33. # option off Apple Silicon).
  34. # skip - install no local voice services.
  35. # Explicit --voice (or VOICEMODE_VOICE_ENGINE env) takes precedence over
  36. # the interactive prompt and the non-interactive skip default.
  37. VOICE_CHOICE="${VOICEMODE_VOICE_ENGINE:-}"
  38. # Parse command line arguments
  39. while [[ $# -gt 0 ]]; do
  40. case $1 in
  41. -y|--yes)
  42. INTERACTIVE=false
  43. shift
  44. ;;
  45. --voice)
  46. VOICE_CHOICE="${2:-}"
  47. shift 2
  48. ;;
  49. --voice=*)
  50. VOICE_CHOICE="${1#*=}"
  51. shift
  52. ;;
  53. *)
  54. shift
  55. ;;
  56. esac
  57. done
  58. # Validate --voice value early so a typo fails fast rather than silently
  59. # falling through to the wrong backend.
  60. case "$VOICE_CHOICE" in
  61. ""|mlx|local|skip) ;;
  62. *)
  63. echo "Error: --voice must be one of: mlx, local, skip (got: '$VOICE_CHOICE')" >&2
  64. exit 1
  65. ;;
  66. esac
  67. # -----------------------------------------------------------------------------
  68. # Color Support
  69. # -----------------------------------------------------------------------------
  70. # Respect NO_COLOR environment variable (see https://no-color.org/)
  71. # Also disable colors when not connected to a terminal
  72. setup_colors() {
  73. if [[ -n "${NO_COLOR:-}" ]] || [[ ! -t 1 ]]; then
  74. # No colors
  75. RED=""
  76. GREEN=""
  77. YELLOW=""
  78. BLUE=""
  79. ORANGE=""
  80. BOLD=""
  81. DIM=""
  82. RESET=""
  83. else
  84. RED=$'\033[0;31m'
  85. GREEN=$'\033[0;32m'
  86. YELLOW=$'\033[0;33m'
  87. BLUE=$'\033[0;34m'
  88. ORANGE=$'\033[38;2;255;135;0m' # Claude Code orange (24-bit truecolor, theme-independent)
  89. BOLD=$'\033[1m'
  90. DIM=$'\033[2m'
  91. RESET=$'\033[0m'
  92. fi
  93. }
  94. # Initialize colors
  95. setup_colors
  96. # -----------------------------------------------------------------------------
  97. # Output helpers
  98. # -----------------------------------------------------------------------------
  99. # Print error message to stderr and exit
  100. die() {
  101. echo "${RED}Error:${RESET} $1" >&2
  102. exit 1
  103. }
  104. # Print status message with checkmark
  105. ok() {
  106. echo "${GREEN}✓${RESET} $1"
  107. }
  108. # Print warning message
  109. warn() {
  110. echo "${YELLOW}⚠${RESET} $1"
  111. }
  112. # Print info message (for progress)
  113. info() {
  114. echo " $1"
  115. }
  116. # Display VoiceMode logo
  117. # Large orange ASCII-art banner (Claude Code orange, ANSI 256-color 208)
  118. show_logo() {
  119. echo ""
  120. printf '%s' "${ORANGE}${BOLD}"
  121. cat <<'EOF'
  122. ╔════════════════════════════════════════════╗
  123. ║ ║
  124. ║ ██╗ ██╗ ██████╗ ██╗ ██████╗███████╗ ║
  125. ║ ██║ ██║██╔═══██╗██║██╔════╝██╔════╝ ║
  126. ║ ██║ ██║██║ ██║██║██║ █████╗ ║
  127. ║ ╚██╗ ██╔╝██║ ██║██║██║ ██╔══╝ ║
  128. ║ ╚████╔╝ ╚██████╔╝██║╚██████╗███████╗ ║
  129. ║ ╚═══╝ ╚═════╝ ╚═╝ ╚═════╝╚══════╝ ║
  130. ║ ║
  131. ║ ███╗ ███╗ ██████╗ ██████╗ ███████╗ ║
  132. ║ ████╗ ████║██╔═══██╗██╔══██╗██╔════╝ ║
  133. ║ ██╔████╔██║██║ ██║██║ ██║█████╗ ║
  134. ║ ██║╚██╔╝██║██║ ██║██║ ██║██╔══╝ ║
  135. ║ ██║ ╚═╝ ██║╚██████╔╝██████╔╝███████╗ ║
  136. ║ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ║
  137. ║ ║
  138. ║ VoiceMode for Claude Code ║
  139. ║ ║
  140. ╚════════════════════════════════════════════╝
  141. EOF
  142. printf '%s\n' "${RESET}"
  143. echo ""
  144. echo "${BOLD}Talk to Claude like a colleague, not a chatbot.${RESET}"
  145. echo ""
  146. echo "${DIM}Transform your AI coding experience with natural voice conversations.${RESET}"
  147. echo ""
  148. }
  149. # Check if a command exists
  150. command_exists() {
  151. command -v "$1" >/dev/null 2>&1
  152. }
  153. # Check if /dev/tty is available for interactive input
  154. # (needed for curl|bash and SSH scenarios)
  155. tty_available() {
  156. # Try to open /dev/tty in a subshell to avoid polluting fd table
  157. # and to properly suppress errors
  158. (exec </dev/tty) 2>/dev/null
  159. }
  160. # -----------------------------------------------------------------------------
  161. # Platform Detection
  162. # -----------------------------------------------------------------------------
  163. detect_os() {
  164. case "$(uname -s)" in
  165. Darwin)
  166. echo "macos"
  167. ;;
  168. Linux)
  169. echo "linux"
  170. ;;
  171. MINGW*|MSYS*|CYGWIN*)
  172. echo "windows"
  173. ;;
  174. *)
  175. die "Unsupported operating system: $(uname -s)"
  176. ;;
  177. esac
  178. }
  179. detect_arch() {
  180. case "$(uname -m)" in
  181. x86_64|amd64)
  182. echo "x86_64"
  183. ;;
  184. arm64|aarch64)
  185. echo "arm64"
  186. ;;
  187. armv7l)
  188. echo "armv7"
  189. ;;
  190. *)
  191. die "Unsupported architecture: $(uname -m)"
  192. ;;
  193. esac
  194. }
  195. detect_linux_distro() {
  196. if [[ -f /etc/os-release ]]; then
  197. # shellcheck source=/dev/null
  198. . /etc/os-release
  199. case "$ID" in
  200. ubuntu|debian|pop|linuxmint|elementary)
  201. echo "debian"
  202. ;;
  203. fedora|rhel|centos|rocky|alma)
  204. echo "fedora"
  205. ;;
  206. arch|manjaro)
  207. echo "arch"
  208. ;;
  209. *)
  210. # Check for ID_LIKE as fallback
  211. case "${ID_LIKE:-}" in
  212. *debian*)
  213. echo "debian"
  214. ;;
  215. *fedora*|*rhel*)
  216. echo "fedora"
  217. ;;
  218. *)
  219. echo "unknown"
  220. ;;
  221. esac
  222. ;;
  223. esac
  224. else
  225. echo "unknown"
  226. fi
  227. }
  228. # -----------------------------------------------------------------------------
  229. # Prerequisite Installation
  230. # -----------------------------------------------------------------------------
  231. # Ensure uv package manager is available
  232. # uv can be installed without sudo
  233. ensure_uv() {
  234. if command_exists uv; then
  235. ok "uv found"
  236. return 0
  237. fi
  238. info "Installing uv package manager..."
  239. if command_exists curl; then
  240. curl -LsSf https://astral.sh/uv/install.sh | sh
  241. elif command_exists wget; then
  242. wget -qO- https://astral.sh/uv/install.sh | sh
  243. else
  244. die "Neither curl nor wget found. Cannot install uv."
  245. fi
  246. # Add uv to PATH for this session
  247. export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
  248. if command_exists uv; then
  249. ok "uv installed"
  250. else
  251. die "uv installation failed. Please install manually: https://docs.astral.sh/uv/getting-started/installation/"
  252. fi
  253. }
  254. # Ensure Rust is available (for ARM64 Kokoro dependencies)
  255. # Uses rustup for latest version since distro packages are often too old
  256. ensure_rust() {
  257. # Check if Rust is already installed and recent enough (1.82+)
  258. if command_exists rustc; then
  259. local rust_version
  260. rust_version=$(rustc --version | sed -E 's/rustc ([0-9]+\.[0-9]+).*/\1/')
  261. local major minor
  262. major=$(echo "$rust_version" | cut -d. -f1)
  263. minor=$(echo "$rust_version" | cut -d. -f2)
  264. if [[ "$major" -gt 1 ]] || { [[ "$major" -eq 1 ]] && [[ "$minor" -ge 82 ]]; }; then
  265. ok "Rust $rust_version found"
  266. return 0
  267. fi
  268. info "Rust $rust_version is too old (need 1.82+), installing via rustup..."
  269. else
  270. info "Installing Rust via rustup..."
  271. fi
  272. if command_exists curl; then
  273. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
  274. elif command_exists wget; then
  275. wget -qO- https://sh.rustup.rs | sh -s -- -y --no-modify-path
  276. else
  277. die "Neither curl nor wget found. Cannot install Rust."
  278. fi
  279. # Add cargo to PATH for this session
  280. export PATH="$HOME/.cargo/bin:$PATH"
  281. if command_exists rustc; then
  282. ok "Rust installed via rustup"
  283. else
  284. die "Rust installation failed. Please install manually: https://rustup.rs/"
  285. fi
  286. }
  287. # -----------------------------------------------------------------------------
  288. # macOS System Dependencies
  289. # -----------------------------------------------------------------------------
  290. # Install all macOS prerequisites (Homebrew + packages + uv) with single confirmation
  291. install_macos_prerequisites() {
  292. local -a packages=(portaudio ffmpeg)
  293. local -a to_install=()
  294. local need_homebrew=false
  295. local need_uv=false
  296. local pkg
  297. # Check if Homebrew is installed
  298. if ! command_exists brew; then
  299. need_homebrew=true
  300. # If no Homebrew, we'll need all packages too
  301. to_install=("${packages[@]}")
  302. else
  303. ok "Homebrew found"
  304. # Check which packages are missing
  305. for pkg in "${packages[@]}"; do
  306. if ! brew list "$pkg" &>/dev/null; then
  307. to_install+=("$pkg")
  308. fi
  309. done
  310. fi
  311. # Check if uv is installed
  312. if ! command_exists uv; then
  313. need_uv=true
  314. else
  315. ok "uv found"
  316. fi
  317. # If nothing to install, we're done
  318. if [[ "$need_homebrew" == "false" ]] && [[ ${#to_install[@]} -eq 0 ]] && [[ "$need_uv" == "false" ]]; then
  319. ok "All dependencies already installed"
  320. return 0
  321. fi
  322. # Show what will be installed
  323. info "The following will be installed:"
  324. if [[ "$need_homebrew" == "true" ]]; then
  325. echo " - Homebrew (package manager)"
  326. fi
  327. for pkg in "${to_install[@]}"; do
  328. echo " - $pkg"
  329. done
  330. if [[ "$need_uv" == "true" ]]; then
  331. echo " - uv (Python package manager)"
  332. fi
  333. # Prompt for confirmation in interactive mode (only if TTY available)
  334. if [[ "$INTERACTIVE" == "true" ]] && tty_available; then
  335. echo ""
  336. read -r -p "Proceed with installation? [Y/n] " response </dev/tty
  337. case "$response" in
  338. [nN][oO]|[nN])
  339. if [[ "$need_homebrew" == "true" ]]; then
  340. die "Homebrew is required for VoiceMode on macOS"
  341. fi
  342. warn "Skipping package installation"
  343. warn "VoiceMode may not work correctly without these packages"
  344. return 0
  345. ;;
  346. esac
  347. elif [[ "$need_homebrew" == "true" ]] && { [[ "$INTERACTIVE" == "false" ]] || ! tty_available; }; then
  348. # Non-interactive mode can't install Homebrew (needs sudo)
  349. die "Homebrew not found. Install it first, then re-run:
  350. /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
  351. fi
  352. # Install Homebrew if needed
  353. if [[ "$need_homebrew" == "true" ]]; then
  354. info "Installing Homebrew (may require password)..."
  355. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  356. # Add Homebrew to PATH for this session (Apple Silicon uses /opt/homebrew)
  357. local brew_path=""
  358. if [[ -x /opt/homebrew/bin/brew ]]; then
  359. brew_path="/opt/homebrew/bin/brew"
  360. elif [[ -x /usr/local/bin/brew ]]; then
  361. brew_path="/usr/local/bin/brew"
  362. fi
  363. if [[ -n "$brew_path" ]]; then
  364. eval "$($brew_path shellenv)"
  365. # Persist to shell profile for future sessions
  366. local shell_profile=""
  367. if [[ -n "${ZSH_VERSION:-}" ]] || [[ "$SHELL" == */zsh ]]; then
  368. shell_profile="$HOME/.zprofile"
  369. else
  370. shell_profile="$HOME/.bash_profile"
  371. fi
  372. local shellenv_line="eval \"\$($brew_path shellenv)\""
  373. if ! grep -q "brew shellenv" "$shell_profile" 2>/dev/null; then
  374. echo "" >> "$shell_profile"
  375. echo "# Homebrew" >> "$shell_profile"
  376. echo "$shellenv_line" >> "$shell_profile"
  377. fi
  378. fi
  379. if command_exists brew; then
  380. ok "Homebrew installed"
  381. else
  382. die "Homebrew installation failed"
  383. fi
  384. fi
  385. # Install packages if needed
  386. if [[ ${#to_install[@]} -gt 0 ]]; then
  387. info "Installing packages..."
  388. brew install "${to_install[@]}"
  389. ok "Packages installed"
  390. fi
  391. # Install uv if needed
  392. if [[ "$need_uv" == "true" ]]; then
  393. info "Installing uv..."
  394. if command_exists curl; then
  395. curl -LsSf https://astral.sh/uv/install.sh | sh
  396. elif command_exists wget; then
  397. wget -qO- https://astral.sh/uv/install.sh | sh
  398. else
  399. die "Neither curl nor wget found. Cannot install uv."
  400. fi
  401. export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
  402. if command_exists uv; then
  403. ok "uv installed"
  404. else
  405. die "uv installation failed"
  406. fi
  407. fi
  408. }
  409. # -----------------------------------------------------------------------------
  410. # Linux System Dependencies
  411. # -----------------------------------------------------------------------------
  412. # Check if a package is installed (distro-specific)
  413. is_package_installed() {
  414. local distro="$1"
  415. local package="$2"
  416. case "$distro" in
  417. debian)
  418. dpkg -s "$package" &>/dev/null
  419. ;;
  420. fedora)
  421. rpm -q "$package" &>/dev/null
  422. ;;
  423. arch)
  424. pacman -Q "$package" &>/dev/null
  425. ;;
  426. *)
  427. return 1
  428. ;;
  429. esac
  430. }
  431. # Install required system packages on Linux (+ uv)
  432. # These are needed for compiling webrtcvad and simpleaudio
  433. install_linux_deps() {
  434. local distro="$1"
  435. local -a all_packages missing_packages
  436. local SUDO=""
  437. local pkg
  438. local need_uv=false
  439. # Use sudo if not running as root and sudo is available
  440. if [[ "$(id -u)" != "0" ]]; then
  441. if command_exists sudo; then
  442. SUDO="sudo"
  443. else
  444. die "This script requires root privileges or sudo. Please run as root or install sudo."
  445. fi
  446. fi
  447. # Define packages per distro
  448. case "$distro" in
  449. debian)
  450. all_packages=(python3-dev gcc libasound2-dev libportaudio2 ffmpeg)
  451. # ARM64 needs g++ for Kokoro's mojimoji dependency
  452. if [[ "$(uname -m)" == "aarch64" || "$(uname -m)" == "arm64" ]]; then
  453. all_packages+=(g++)
  454. fi
  455. ;;
  456. fedora)
  457. all_packages=(python3-devel gcc alsa-lib-devel portaudio ffmpeg)
  458. # ARM64 needs g++ for Kokoro's mojimoji dependency
  459. if [[ "$(uname -m)" == "aarch64" || "$(uname -m)" == "arm64" ]]; then
  460. all_packages+=(gcc-c++)
  461. fi
  462. ;;
  463. arch)
  464. all_packages=(python gcc alsa-lib portaudio ffmpeg)
  465. # Arch gcc package includes g++, no extras needed
  466. ;;
  467. *)
  468. warn "Unknown Linux distro. Please install build dependencies manually:"
  469. echo " - C compiler (gcc)"
  470. echo " - Python development headers"
  471. echo " - ALSA development libraries"
  472. echo " - PortAudio library"
  473. echo " - FFmpeg"
  474. return 0
  475. ;;
  476. esac
  477. # Check which packages are missing
  478. missing_packages=()
  479. for pkg in "${all_packages[@]}"; do
  480. if ! is_package_installed "$distro" "$pkg"; then
  481. missing_packages+=("$pkg")
  482. fi
  483. done
  484. # Check if uv is installed
  485. if ! command_exists uv; then
  486. need_uv=true
  487. else
  488. ok "uv found"
  489. fi
  490. # If everything is installed, we're done
  491. if [[ ${#missing_packages[@]} -eq 0 ]] && [[ "$need_uv" == "false" ]]; then
  492. ok "All dependencies already installed"
  493. return 0
  494. fi
  495. # Show what needs to be installed
  496. info "The following will be installed:"
  497. for pkg in "${missing_packages[@]}"; do
  498. echo " - $pkg"
  499. done
  500. if [[ "$need_uv" == "true" ]]; then
  501. echo " - uv (Python package manager)"
  502. fi
  503. # Prompt for confirmation in interactive mode (only if TTY available)
  504. if [[ "$INTERACTIVE" == "true" ]] && tty_available; then
  505. echo ""
  506. read -r -p "Install these? [Y/n] " response </dev/tty
  507. case "$response" in
  508. [nN][oO]|[nN])
  509. warn "Skipping dependency installation"
  510. warn "VoiceMode may not work correctly without these packages"
  511. return 0
  512. ;;
  513. esac
  514. fi
  515. # Install missing packages
  516. if [[ ${#missing_packages[@]} -gt 0 ]]; then
  517. info "Installing packages..."
  518. case "$distro" in
  519. debian)
  520. export DEBIAN_FRONTEND=noninteractive
  521. $SUDO apt-get update -qq >/dev/null
  522. $SUDO apt-get install -y -qq "${missing_packages[@]}" >/dev/null
  523. ;;
  524. fedora)
  525. $SUDO dnf install -y -q "${missing_packages[@]}" >/dev/null
  526. ;;
  527. arch)
  528. $SUDO pacman -S --noconfirm -q "${missing_packages[@]}" >/dev/null
  529. ;;
  530. esac
  531. ok "Packages installed"
  532. fi
  533. # Install uv if needed
  534. if [[ "$need_uv" == "true" ]]; then
  535. info "Installing uv..."
  536. if command_exists curl; then
  537. curl -LsSf https://astral.sh/uv/install.sh | sh
  538. elif command_exists wget; then
  539. wget -qO- https://astral.sh/uv/install.sh | sh
  540. else
  541. die "Neither curl nor wget found. Cannot install uv."
  542. fi
  543. export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
  544. if command_exists uv; then
  545. ok "uv installed"
  546. else
  547. die "uv installation failed"
  548. fi
  549. fi
  550. }
  551. # -----------------------------------------------------------------------------
  552. # System Dependencies (orchestration)
  553. # -----------------------------------------------------------------------------
  554. # Install all system dependencies for the detected platform
  555. install_system_deps() {
  556. local os="$1"
  557. local arch="$2"
  558. local distro
  559. case "$os" in
  560. macos)
  561. ok "Platform: macOS ($arch)"
  562. install_macos_prerequisites
  563. ;;
  564. linux)
  565. distro=$(detect_linux_distro)
  566. ok "Platform: Linux/$distro ($arch)"
  567. install_linux_deps "$distro"
  568. # ARM64 Linux needs Rust via rustup for Kokoro dependencies
  569. if [[ "$arch" == "arm64" ]]; then
  570. ensure_rust
  571. fi
  572. ;;
  573. windows)
  574. die "Windows is not yet supported. Please use WSL2 instead."
  575. ;;
  576. esac
  577. }
  578. # -----------------------------------------------------------------------------
  579. # Local Voice Services (Whisper & Kokoro)
  580. # -----------------------------------------------------------------------------
  581. # Check if Whisper STT is installed
  582. is_whisper_installed() {
  583. [[ -d "$HOME/.voicemode/services/whisper" ]]
  584. }
  585. # Check if Kokoro TTS is installed
  586. is_kokoro_installed() {
  587. [[ -d "$HOME/.voicemode/services/kokoro" ]]
  588. }
  589. # -----------------------------------------------------------------------------
  590. # mlx-audio (Apple Silicon) -- VM-1330
  591. # -----------------------------------------------------------------------------
  592. #
  593. # mlx-audio is a single MLX-native server (STT + TTS + clone-voice) that runs
  594. # on its OWN port 8890. We point VoiceMode at it by putting the mlx-audio URL
  595. # FIRST in the preference-ordered base-URL lists (OpenAI kept as a trailing
  596. # cloud fallback). This mirrors voice_mode/tools/mlx_audio/install.py and the
  597. # VM-1088 port decision (8880 compat-shim was rejected).
  598. #
  599. # IMPORTANT (VM-1318 gate): mlx-audio is RECOMMENDED + opt-in on Apple
  600. # Silicon. It is NOT the silent non-interactive default until the
  601. # security/project-health review (VM-1318) clears. Selection is explicit:
  602. # an interactive choice, or an explicit --voice mlx flag.
  603. MLX_AUDIO_PORT=8890
  604. WHISPER_CPP_PORT=2022
  605. KOKORO_PORT=8880
  606. # True only on Apple Silicon (macOS arm64) -- the hard gate per ADR VM-1086.
  607. # Mirrors voice_mode/tools/mlx_audio/install.py::_is_apple_silicon and the
  608. # assess_voice_capability "excellent" branch.
  609. is_apple_silicon() {
  610. local os="$1"
  611. local arch="$2"
  612. [[ "$os" == "macos" && "$arch" == "arm64" ]]
  613. }
  614. # Check if mlx-audio is already installed (uv-tool entry point present).
  615. is_mlx_audio_installed() {
  616. [[ -x "$HOME/.local/bin/mlx_audio.server" ]]
  617. }
  618. # Point VoiceMode at the chosen STT + TTS backends by writing the two
  619. # preference-ordered base-URL lists separately. STT always goes to
  620. # whisper.cpp (VM-1421); only the TTS URL varies between mlx-audio (8890)
  621. # and Kokoro (8880). OpenAI stays as the trailing cloud fallback on both
  622. # so a cold local server still degrades gracefully. Uses the existing
  623. # `voicemode config set` primitive (writes ~/.voicemode/voicemode.env) --
  624. # no fragile shell-side env munging.
  625. configure_voice_urls() {
  626. local stt_url="$1"
  627. local tts_url="$2"
  628. local stt_urls="${stt_url},https://api.openai.com/v1"
  629. local tts_urls="${tts_url},https://api.openai.com/v1"
  630. info "Pointing VoiceMode at STT ${stt_url} and TTS ${tts_url}..."
  631. if voicemode config set VOICEMODE_STT_BASE_URLS "$stt_urls" \
  632. && voicemode config set VOICEMODE_TTS_BASE_URLS "$tts_urls"; then
  633. ok "VoiceMode configured (OpenAI cloud fallback kept)"
  634. else
  635. warn "Could not write voice base-URL config"
  636. warn "Set it later with:"
  637. warn " voicemode config set VOICEMODE_STT_BASE_URLS \"$stt_urls\""
  638. warn " voicemode config set VOICEMODE_TTS_BASE_URLS \"$tts_urls\""
  639. fi
  640. }
  641. # Install whisper.cpp via the existing CLI primitive. install.sh stays a
  642. # thin orchestrator -- the build, launchd plist and model download all live
  643. # in `voicemode whisper install`.
  644. install_whisper_cpp() {
  645. if is_whisper_installed; then
  646. ok "whisper.cpp already installed"
  647. return 0
  648. fi
  649. echo ""
  650. echo "${BOLD}Installing whisper.cpp${RESET} (on-device STT on port ${WHISPER_CPP_PORT})"
  651. if voicemode whisper install; then
  652. ok "whisper.cpp installed"
  653. else
  654. warn "whisper.cpp installation failed - retry with: voicemode whisper install"
  655. return 1
  656. fi
  657. }
  658. # Install mlx-audio via the existing CLI primitive. install.sh stays a thin
  659. # orchestrator -- the uv tool install + post-install checks + launchd plist all
  660. # live in `voicemode service install mlx-audio` (mlx_audio_install()),
  661. # which is already Apple-Silicon-gated. URL config is the caller's job
  662. # (see install_voice_services) so STT + TTS get written together.
  663. install_mlx_audio() {
  664. if is_mlx_audio_installed; then
  665. ok "mlx-audio already installed"
  666. return 0
  667. fi
  668. echo ""
  669. echo "${BOLD}Installing mlx-audio${RESET} (Apple Silicon on-device TTS on port ${MLX_AUDIO_PORT})"
  670. info "No Xcode, no source compile. Models pull on first voice use."
  671. if voicemode service install mlx-audio; then
  672. ok "mlx-audio installed"
  673. else
  674. warn "mlx-audio installation failed - retry with: voicemode service install mlx-audio"
  675. return 1
  676. fi
  677. }
  678. # Install Kokoro-FastAPI TTS via the existing CLI primitive. Used both for
  679. # the explicit "local" choice and as the Apple-Silicon fallback when
  680. # mlx-audio install fails. URL config stays at the call-site.
  681. install_kokoro() {
  682. if is_kokoro_installed; then
  683. ok "Kokoro already installed"
  684. return 0
  685. fi
  686. echo ""
  687. echo "${BOLD}Installing Kokoro${RESET} (cross-platform TTS on port ${KOKORO_PORT})"
  688. if voicemode kokoro install; then
  689. ok "Kokoro installed"
  690. else
  691. warn "Kokoro installation failed - retry with: voicemode kokoro install"
  692. return 1
  693. fi
  694. }
  695. # Resolve the voice backend choice on Apple Silicon.
  696. # Precedence (per VM-1330 plan):
  697. # explicit --voice flag > interactive prompt > non-interactive skip
  698. # Echoes one of: mlx | local | skip
  699. # Honors the VM-1318 gate: non-interactive without an explicit --voice
  700. # stays "skip" (the prior behaviour) -- mlx is never the silent default.
  701. resolve_apple_silicon_choice() {
  702. # Explicit flag / env wins outright.
  703. if [[ -n "$VOICE_CHOICE" ]]; then
  704. echo "$VOICE_CHOICE"
  705. return 0
  706. fi
  707. if [[ "$INTERACTIVE" == "true" ]] && tty_available; then
  708. echo "" >&2
  709. echo "${BOLD}Install local voice services${RESET} -- speech-to-text & text-to-speech?" >&2
  710. echo "" >&2
  711. echo " [1] Whisper (STT) + mlx-audio (TTS) -- fast on-device, voice cloning ${GREEN}(recommended)${RESET}" >&2
  712. echo " [2] Whisper (STT) + Kokoro (TTS) -- classic, cross-platform" >&2
  713. echo " [3] no thanks" >&2
  714. echo "" >&2
  715. local response
  716. read -r -p "> " response </dev/tty
  717. case "$response" in
  718. ""|1) echo "mlx" ;;
  719. 2) echo "local" ;;
  720. 3|[sS]) echo "skip" ;;
  721. *)
  722. warn "Unrecognised choice '$response' -- defaulting to recommended (Whisper + mlx-audio)" >&2
  723. echo "mlx"
  724. ;;
  725. esac
  726. return 0
  727. fi
  728. # Non-interactive, no explicit choice: preserve prior behaviour
  729. # (skip the large download). Do NOT silently default to mlx --
  730. # that decision is gated by VM-1318.
  731. echo "skip"
  732. }
  733. # Assess system capability for local voice services
  734. # Returns: "excellent", "good", or "limited"
  735. assess_voice_capability() {
  736. local os="$1"
  737. local arch="$2"
  738. local ram_gb=0
  739. # Get RAM in GB
  740. case "$os" in
  741. macos)
  742. ram_gb=$(( $(sysctl -n hw.memsize) / 1024 / 1024 / 1024 ))
  743. ;;
  744. linux)
  745. ram_gb=$(( $(grep MemTotal /proc/meminfo | awk '{print $2}') / 1024 / 1024 ))
  746. ;;
  747. esac
  748. # Apple Silicon Mac: excellent (unified memory, Neural Engine)
  749. # Everything else: depends on RAM
  750. if [[ "$os" == "macos" && "$arch" == "arm64" ]]; then
  751. echo "excellent"
  752. elif [[ $ram_gb -ge 16 ]]; then
  753. echo "good"
  754. elif [[ $ram_gb -ge 8 ]]; then
  755. echo "limited"
  756. else
  757. echo "limited"
  758. fi
  759. }
  760. # Get human-readable capability message
  761. get_capability_message() {
  762. local capability="$1"
  763. case "$capability" in
  764. excellent)
  765. echo "Local voice services should run excellently on this system."
  766. ;;
  767. good)
  768. echo "Local voice services should run well on this system."
  769. ;;
  770. limited)
  771. echo "Local voice services may be slow on this system."
  772. ;;
  773. esac
  774. }
  775. # Print the install status of each voice engine relevant to this platform,
  776. # mirroring the existing "✓ ... already installed" style. On Apple Silicon
  777. # this also covers mlx-audio; off Apple Silicon mlx-audio is never mentioned
  778. # (it can't run there).
  779. show_voice_status() {
  780. local os="$1"
  781. local arch="$2"
  782. echo ""
  783. echo "${BOLD}Local voice services${RESET}"
  784. if is_apple_silicon "$os" "$arch"; then
  785. if is_mlx_audio_installed; then
  786. ok "mlx-audio already installed"
  787. else
  788. info "${DIM}–${RESET} mlx-audio not installed"
  789. fi
  790. fi
  791. if is_whisper_installed; then
  792. ok "Whisper STT already installed"
  793. else
  794. info "${DIM}–${RESET} Whisper STT not installed"
  795. fi
  796. if is_kokoro_installed; then
  797. ok "Kokoro TTS already installed"
  798. else
  799. info "${DIM}–${RESET} Kokoro TTS not installed"
  800. fi
  801. }
  802. # Prompt user to install local voice services
  803. install_voice_services() {
  804. local os="$1"
  805. local arch="$2"
  806. local whisper_installed=false
  807. local kokoro_installed=false
  808. # Set when the user has explicitly opted into whisper.cpp+Kokoro
  809. # (Apple-Silicon "local" choice). Lets that choice bypass the legacy
  810. # confirmation prompt / non-interactive skip below and install directly.
  811. local explicit_local=false
  812. # STATUS DISPLAY FIRST: report what's installed before any prompt.
  813. show_voice_status "$os" "$arch"
  814. # Track install state (status already printed above; don't re-print
  815. # the per-service "already installed" lines a second time).
  816. if is_whisper_installed; then
  817. whisper_installed=true
  818. fi
  819. if is_kokoro_installed; then
  820. kokoro_installed=true
  821. fi
  822. # --- Apple Silicon: whisper.cpp (STT) + choice of TTS engine (VM-1421) ---
  823. # All three Apple-Silicon paths (mlx / local / skip) return from inside
  824. # the case below -- the off-Apple-Silicon legacy block further down
  825. # never runs on arm64 macs. This block MUST run BEFORE the "both
  826. # already installed" early-return so a user on a prior release (likely
  827. # already has whisper + Kokoro) is still offered the mlx-audio TTS
  828. # upgrade.
  829. if is_apple_silicon "$os" "$arch"; then
  830. local stt_url="http://127.0.0.1:${WHISPER_CPP_PORT}/v1"
  831. local mlx_tts_url="http://127.0.0.1:${MLX_AUDIO_PORT}/v1"
  832. local kokoro_tts_url="http://127.0.0.1:${KOKORO_PORT}/v1"
  833. # Already-satisfied shortcut: if whisper.cpp + mlx-audio are both
  834. # installed and the user did NOT explicitly force a backend,
  835. # there's nothing to ask. Just idempotently write the split URLs
  836. # and finish cleanly. An explicit --voice (or VOICEMODE_VOICE_ENGINE)
  837. # always wins and bypasses this shortcut so the user can force the
  838. # other path.
  839. if is_whisper_installed && is_mlx_audio_installed && [[ -z "$VOICE_CHOICE" ]]; then
  840. configure_voice_urls "$stt_url" "$mlx_tts_url"
  841. ok "Whisper + mlx-audio already installed and configured -- all set, nothing to do"
  842. return 0
  843. fi
  844. local choice
  845. choice=$(resolve_apple_silicon_choice)
  846. case "$choice" in
  847. mlx)
  848. # Whisper is load-bearing for STT regardless of which TTS
  849. # is chosen (VM-1421 -- mlx-whisper repetition bug VM-94
  850. # blocks using mlx-audio for STT). Install whisper.cpp
  851. # first, then mlx-audio for TTS. If mlx-audio install
  852. # fails, install Kokoro and re-point TTS at port
  853. # ${KOKORO_PORT} instead of leaving the user with no TTS.
  854. if ! install_whisper_cpp; then
  855. warn "STT not available -- retry with: voicemode whisper install"
  856. return 1
  857. fi
  858. if install_mlx_audio; then
  859. configure_voice_urls "$stt_url" "$mlx_tts_url"
  860. return 0
  861. fi
  862. warn "mlx-audio failed -- falling back to Kokoro for TTS"
  863. if install_kokoro; then
  864. configure_voice_urls "$stt_url" "$kokoro_tts_url"
  865. return 0
  866. fi
  867. warn "Kokoro fallback also failed -- TTS not configured"
  868. return 1
  869. ;;
  870. skip)
  871. info "Skipping local voice services"
  872. info "Install Whisper + mlx-audio later with:"
  873. info " voicemode whisper install && voicemode service install mlx-audio"
  874. info " (or Whisper + Kokoro: voicemode whisper install && voicemode kokoro install)"
  875. return 0
  876. ;;
  877. local)
  878. # Whisper (STT) + Kokoro (TTS). Install both, then write
  879. # the split URLs explicitly (don't rely on package
  880. # defaults). Treat as explicit opt-in so the legacy
  881. # confirm/skip prompt below is bypassed -- but skip the
  882. # legacy install block by handling it inline here.
  883. if install_whisper_cpp && install_kokoro; then
  884. configure_voice_urls "$stt_url" "$kokoro_tts_url"
  885. return 0
  886. fi
  887. warn "Whisper + Kokoro install incomplete -- check messages above"
  888. return 1
  889. ;;
  890. esac
  891. fi
  892. # Off Apple Silicon only (the arm64 branch above always returns from
  893. # inside its case). If both are installed, nothing to do.
  894. if [[ "$whisper_installed" == "true" && "$kokoro_installed" == "true" ]]; then
  895. return 0
  896. fi
  897. # Assess system capability
  898. local capability
  899. capability=$(assess_voice_capability "$os" "$arch")
  900. local capability_msg
  901. capability_msg=$(get_capability_message "$capability")
  902. # Show info about local voice services
  903. echo ""
  904. echo "${BOLD}Local Voice Services${RESET}"
  905. info "$capability_msg"
  906. # Build list of what would be installed
  907. local services_to_install=""
  908. if [[ "$whisper_installed" == "false" ]]; then
  909. services_to_install="Whisper (STT)"
  910. fi
  911. if [[ "$kokoro_installed" == "false" ]]; then
  912. if [[ -n "$services_to_install" ]]; then
  913. services_to_install="$services_to_install, Kokoro (TTS)"
  914. else
  915. services_to_install="Kokoro (TTS)"
  916. fi
  917. fi
  918. # Show download size estimate
  919. local download_size="~3GB"
  920. if [[ "$whisper_installed" == "false" && "$kokoro_installed" == "false" ]]; then
  921. download_size="~3GB total"
  922. elif [[ "$whisper_installed" == "false" ]]; then
  923. download_size="~1.5GB"
  924. elif [[ "$kokoro_installed" == "false" ]]; then
  925. download_size="~1.5GB"
  926. fi
  927. info "Available: $services_to_install ($download_size download)"
  928. # Honor an explicit backend choice on ANY platform (VM-1330). On
  929. # non-Apple-Silicon, `--voice mlx` is not viable -- mlx-audio is
  930. # Apple-Silicon-only -- so warn and treat it as the local path.
  931. if [[ "$explicit_local" == "false" && -n "$VOICE_CHOICE" ]]; then
  932. case "$VOICE_CHOICE" in
  933. skip)
  934. info "Skipping local voice services (--voice skip)"
  935. info "Install later with: voicemode whisper install && voicemode kokoro install"
  936. return 0
  937. ;;
  938. mlx)
  939. # Reached here only if NOT Apple Silicon (the arm64 mac
  940. # branch above handles mlx and returns). mlx-audio can't
  941. # run here -- fall back to whisper.cpp + Kokoro.
  942. warn "mlx-audio requires Apple Silicon (macOS arm64); using whisper.cpp + Kokoro instead"
  943. explicit_local=true
  944. ;;
  945. local)
  946. explicit_local=true
  947. ;;
  948. esac
  949. fi
  950. # Prompt for installation. An explicit local opt-in bypasses both the
  951. # confirmation prompt and the non-interactive skip default.
  952. if [[ "$explicit_local" == "true" ]]; then
  953. info "Installing Whisper (STT) + Kokoro (TTS) (explicitly selected)"
  954. elif [[ "$INTERACTIVE" == "true" ]] && tty_available; then
  955. echo ""
  956. read -r -p "Install Whisper (STT) + Kokoro (TTS)? [Y/n] " response </dev/tty
  957. case "$response" in
  958. [nN][oO]|[nN])
  959. info "Skipping local voice services"
  960. info "You can install them later with: voicemode whisper install && voicemode kokoro install"
  961. return 0
  962. ;;
  963. esac
  964. else
  965. # Non-interactive: skip voice services by default (they're large downloads)
  966. info "Skipping local voice services (non-interactive mode)"
  967. info "Install later with: voicemode whisper install && voicemode kokoro install"
  968. return 0
  969. fi
  970. # Install Whisper if needed
  971. if [[ "$whisper_installed" == "false" ]]; then
  972. info "Installing Whisper (STT)..."
  973. if voicemode whisper install; then
  974. ok "Whisper (STT) installed"
  975. else
  976. warn "Whisper installation failed - you can retry with: voicemode whisper install"
  977. fi
  978. fi
  979. # Install Kokoro if needed
  980. if [[ "$kokoro_installed" == "false" ]]; then
  981. info "Installing Kokoro (TTS)..."
  982. if voicemode kokoro install; then
  983. ok "Kokoro (TTS) installed"
  984. else
  985. warn "Kokoro installation failed - you can retry with: voicemode kokoro install"
  986. fi
  987. fi
  988. # Write split URLs explicitly (don't rely on package defaults) so STT
  989. # lands on whisper.cpp and TTS on Kokoro -- matches the Apple-Silicon
  990. # "local" branch above (VM-1421).
  991. if is_whisper_installed && is_kokoro_installed; then
  992. configure_voice_urls \
  993. "http://127.0.0.1:${WHISPER_CPP_PORT}/v1" \
  994. "http://127.0.0.1:${KOKORO_PORT}/v1"
  995. fi
  996. }
  997. # -----------------------------------------------------------------------------
  998. # VoiceMode Installation
  999. # -----------------------------------------------------------------------------
  1000. # Install VoiceMode using uv
  1001. install_voicemode() {
  1002. info "Installing VoiceMode..."
  1003. local output
  1004. # Use uv tool install for isolated tool installation
  1005. # Capture output to check for "already installed" message
  1006. if output=$(uv tool install "$VOICEMODE_PACKAGE" 2>&1); then
  1007. if echo "$output" | grep -q "already installed"; then
  1008. ok "VoiceMode already installed"
  1009. else
  1010. ok "VoiceMode installed"
  1011. fi
  1012. else
  1013. # Installation failed
  1014. if command_exists voicemode; then
  1015. # Already installed but uv failed (shouldn't happen normally)
  1016. ok "VoiceMode already installed"
  1017. else
  1018. echo "$output" >&2
  1019. die "VoiceMode installation failed"
  1020. fi
  1021. fi
  1022. }
  1023. # Verify VoiceMode installation and show version
  1024. verify_voicemode() {
  1025. # Refresh PATH to pick up newly installed tools
  1026. export PATH="$HOME/.local/bin:$PATH"
  1027. if ! command_exists voicemode; then
  1028. die "VoiceMode command not found after installation.
  1029. Please ensure ~/.local/bin is in your PATH:
  1030. export PATH=\"\$HOME/.local/bin:\$PATH\""
  1031. fi
  1032. local version
  1033. version=$(voicemode --version 2>/dev/null | sed 's/VoiceMode, version //' || echo "unknown")
  1034. ok "VoiceMode $version ready"
  1035. }
  1036. # Display next steps for the user
  1037. show_next_steps() {
  1038. echo ""
  1039. echo "Next steps:"
  1040. echo " voicemode --help Show available commands"
  1041. echo " voicemode status Check service status"
  1042. echo ""
  1043. echo "Documentation: https://getvoicemode.com/docs"
  1044. }
  1045. # -----------------------------------------------------------------------------
  1046. # Main
  1047. # -----------------------------------------------------------------------------
  1048. main() {
  1049. local os arch distro
  1050. # Detect platform
  1051. os=$(detect_os)
  1052. arch=$(detect_arch)
  1053. # Display logo
  1054. show_logo
  1055. # Install system dependencies (includes uv)
  1056. install_system_deps "$os" "$arch"
  1057. # Install and verify VoiceMode
  1058. install_voicemode
  1059. verify_voicemode
  1060. # Offer to install local voice services
  1061. install_voice_services "$os" "$arch"
  1062. show_next_steps
  1063. }
  1064. main "$@"
voice_mode/templates/scripts/start-voicemode-serve.sh · Bundled script · 133 lines · 1 finding marked
  1. #!/bin/bash
  2. # VoiceMode HTTP Server Startup Script
  3. # This script is used by both macOS (launchd) and Linux (systemd) to start the VoiceMode HTTP server
  4. # It sources the voicemode.env file to get configuration for VOICEMODE_SERVE_* variables
  5. # VoiceMode configuration directory
  6. VOICEMODE_DIR="$HOME/.voicemode"
  7. LOG_DIR="$VOICEMODE_DIR/logs/serve"
  8. # Create log directory if it doesn't exist
  9. mkdir -p "$LOG_DIR"
  10. # Log file for this script (separate from server logs)
  11. STARTUP_LOG="$LOG_DIR/startup.log"
  12. # >>> voicemode_load_env_file — safe replacement for `source` (GHSA-h97v-r3jw-cf6f) >>>
  13. # Load KEY=VALUE pairs from voicemode.env as INERT DATA. We must NOT `source`
  14. # the file: bash runs command substitution even inside double quotes, so a
  15. # value like VOICEMODE_VOICES='x$(rm -rf ~)' would execute as the service user
    • Note: Quoted as data in code: Runs `rm -rf` against a root or home-directory path
    • Line 20 on GitHub
  16. # on every start. This reader only ever assigns; it never evaluates the value.
  17. voicemode_load_env_file() {
  18. local file="$1" line key val
  19. [ -f "$file" ] || return 0
  20. while IFS= read -r line || [ -n "$line" ]; do
  21. # Trim leading whitespace
  22. line="${line#"${line%%[![:space:]]*}"}"
  23. # Skip blank lines and comments
  24. if [ -z "$line" ]; then continue; fi
  25. case "$line" in '#'*) continue ;; esac
  26. # Require KEY=VALUE with a valid shell-identifier key
  27. case "$line" in [A-Za-z_]*=*) : ;; *) continue ;; esac
  28. key="${line%%=*}"
  29. case "$key" in *[!A-Za-z0-9_]*) continue ;; esac
  30. val="${line#*=}"
  31. # Strip ONE layer of surrounding quotes; contents are never expanded.
  32. # (Multiline-quoted values are read by the Python config loader, not
  33. # needed by this script — their continuation lines are skipped above.)
  34. case "$val" in
  35. \"*\") val="${val#\"}"; val="${val%\"}" ;;
  36. \'*\') val="${val#\'}"; val="${val%\'}" ;;
  37. esac
  38. export "$key=$val"
  39. done < "$file"
  40. return 0
  41. }
  42. # <<< voicemode_load_env_file <<<
  43. # Load voicemode configuration if it exists (without executing it)
  44. if [ -f "$VOICEMODE_DIR/voicemode.env" ]; then
  45. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Loading voicemode.env" >> "$STARTUP_LOG"
  46. voicemode_load_env_file "$VOICEMODE_DIR/voicemode.env"
  47. else
  48. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Warning: voicemode.env not found, using defaults" >> "$STARTUP_LOG"
  49. fi
  50. # Configuration with environment variable support (defaults match config.py)
  51. SERVE_HOST="${VOICEMODE_SERVE_HOST:-127.0.0.1}"
  52. SERVE_PORT="${VOICEMODE_SERVE_PORT:-8765}"
  53. SERVE_TRANSPORT="${VOICEMODE_SERVE_TRANSPORT:-streamable-http}"
  54. SERVE_LOG_LEVEL="${VOICEMODE_SERVE_LOG_LEVEL:-info}"
  55. # Security configuration
  56. SERVE_ALLOW_LOCAL="${VOICEMODE_SERVE_ALLOW_LOCAL:-true}"
  57. SERVE_ALLOW_ANTHROPIC="${VOICEMODE_SERVE_ALLOW_ANTHROPIC:-false}"
  58. SERVE_ALLOW_TAILSCALE="${VOICEMODE_SERVE_ALLOW_TAILSCALE:-false}"
  59. SERVE_ALLOWED_IPS="${VOICEMODE_SERVE_ALLOWED_IPS:-}"
  60. SERVE_SECRET="${VOICEMODE_SERVE_SECRET:-}"
  61. SERVE_TOKEN="${VOICEMODE_SERVE_TOKEN:-}"
  62. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting VoiceMode HTTP server" >> "$STARTUP_LOG"
  63. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Host: $SERVE_HOST" >> "$STARTUP_LOG"
  64. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Port: $SERVE_PORT" >> "$STARTUP_LOG"
  65. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Transport: $SERVE_TRANSPORT" >> "$STARTUP_LOG"
  66. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Log level: $SERVE_LOG_LEVEL" >> "$STARTUP_LOG"
  67. # Build command arguments
  68. CMD_ARGS=(
  69. --host "$SERVE_HOST"
  70. --port "$SERVE_PORT"
  71. --transport "$SERVE_TRANSPORT"
  72. --log-level "$SERVE_LOG_LEVEL"
  73. )
  74. # Add security flags based on configuration
  75. if [ "$SERVE_ALLOW_LOCAL" = "true" ]; then
  76. CMD_ARGS+=(--allow-local)
  77. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Allowing local connections" >> "$STARTUP_LOG"
  78. else
  79. CMD_ARGS+=(--no-allow-local)
  80. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Blocking local connections" >> "$STARTUP_LOG"
  81. fi
  82. if [ "$SERVE_ALLOW_ANTHROPIC" = "true" ]; then
  83. CMD_ARGS+=(--allow-anthropic)
  84. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Allowing Anthropic IP ranges" >> "$STARTUP_LOG"
  85. fi
  86. if [ "$SERVE_ALLOW_TAILSCALE" = "true" ]; then
  87. CMD_ARGS+=(--allow-tailscale)
  88. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Allowing Tailscale IP range" >> "$STARTUP_LOG"
  89. fi
  90. # Add custom allowed IPs if configured (comma-separated list)
  91. if [ -n "$SERVE_ALLOWED_IPS" ]; then
  92. IFS=',' read -ra IP_ARRAY <<< "$SERVE_ALLOWED_IPS"
  93. for ip in "${IP_ARRAY[@]}"; do
  94. # Trim whitespace
  95. ip=$(echo "$ip" | xargs)
  96. if [ -n "$ip" ]; then
  97. CMD_ARGS+=(--allow-ip "$ip")
  98. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Allowing custom IP: $ip" >> "$STARTUP_LOG"
  99. fi
  100. done
  101. fi
  102. # Add authentication if configured
  103. if [ -n "$SERVE_SECRET" ]; then
  104. CMD_ARGS+=(--secret "$SERVE_SECRET")
  105. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Secret path authentication enabled" >> "$STARTUP_LOG"
  106. fi
  107. if [ -n "$SERVE_TOKEN" ]; then
  108. CMD_ARGS+=(--token "$SERVE_TOKEN")
  109. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Bearer token authentication enabled" >> "$STARTUP_LOG"
  110. fi
  111. echo "[$(date '+%Y-%m-%d %H:%M:%S')] Executing: voicemode serve ${CMD_ARGS[*]}" >> "$STARTUP_LOG"
  112. # Start VoiceMode HTTP server
  113. # Using exec to replace this script process with the server
  114. # Use voicemode CLI command which is in ~/.local/bin (added to PATH by launchd plist)
  115. exec voicemode serve "${CMD_ARGS[@]}"
voice_mode/templates/scripts/start-whisper-server.sh · Bundled script · 212 lines · 1 finding marked
  1. #!/usr/bin/env bash
  2. set -o nounset -o pipefail -o errexit
  3. # Whisper Service Startup Script
  4. # This script is used by both macOS (launchd) and Linux (systemd) to start the whisper service
  5. # It sources the voicemode.env file to get configuration, especially VOICEMODE_WHISPER_MODEL
  6. #
  7. # Features:
  8. # - Startup health check with 120s timeout
  9. # - Auto-fallback: disables CoreML if server hangs during init
  10. # - Thread count reduction when CoreML is active (commented out pending VM-642)
  11. # Determine whisper directory (script is in bin/, whisper root is parent)
  12. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  13. WHISPER_DIR="$(dirname "$SCRIPT_DIR")"
  14. # Voicemode configuration directory
  15. VOICEMODE_DIR="$HOME/.voicemode"
  16. LOG_DIR="$VOICEMODE_DIR/logs/whisper"
  17. # Create log directory if it doesn't exist
  18. mkdir -p "$LOG_DIR"
  19. # Log file for this script (separate from whisper server logs)
  20. STARTUP_LOG="$LOG_DIR/startup.log"
  21. log() {
  22. echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$STARTUP_LOG"
  23. }
  24. # >>> voicemode_load_env_file — safe replacement for `source` (GHSA-h97v-r3jw-cf6f) >>>
  25. # Load KEY=VALUE pairs from voicemode.env as INERT DATA. We must NOT `source`
  26. # the file: bash runs command substitution even inside double quotes, so a
  27. # value like VOICEMODE_VOICES='x$(rm -rf ~)' would execute as the service user
    • Note: Quoted as data in code: Runs `rm -rf` against a root or home-directory path
    • Line 34 on GitHub
  28. # on every start. This reader only ever assigns; it never evaluates the value.
  29. voicemode_load_env_file() {
  30. local file="$1" line key val
  31. [ -f "$file" ] || return 0
  32. while IFS= read -r line || [ -n "$line" ]; do
  33. # Trim leading whitespace
  34. line="${line#"${line%%[![:space:]]*}"}"
  35. # Skip blank lines and comments
  36. if [ -z "$line" ]; then continue; fi
  37. case "$line" in '#'*) continue ;; esac
  38. # Require KEY=VALUE with a valid shell-identifier key
  39. case "$line" in [A-Za-z_]*=*) : ;; *) continue ;; esac
  40. key="${line%%=*}"
  41. case "$key" in *[!A-Za-z0-9_]*) continue ;; esac
  42. val="${line#*=}"
  43. # Strip ONE layer of surrounding quotes; contents are never expanded.
  44. # (Multiline-quoted values are read by the Python config loader, not
  45. # needed by this script — their continuation lines are skipped above.)
  46. case "$val" in
  47. \"*\") val="${val#\"}"; val="${val%\"}" ;;
  48. \'*\') val="${val#\'}"; val="${val%\'}" ;;
  49. esac
  50. export "$key=$val"
  51. done < "$file"
  52. return 0
  53. }
  54. # <<< voicemode_load_env_file <<<
  55. # Load voicemode configuration if it exists (without executing it)
  56. if [ -f "$VOICEMODE_DIR/voicemode.env" ]; then
  57. log "Loading voicemode.env"
  58. voicemode_load_env_file "$VOICEMODE_DIR/voicemode.env"
  59. else
  60. log "Warning: voicemode.env not found"
  61. fi
  62. # Model selection with environment variable support
  63. MODEL_NAME="${VOICEMODE_WHISPER_MODEL:-base}"
  64. MODEL_PATH="$WHISPER_DIR/models/ggml-$MODEL_NAME.bin"
  65. log "Starting whisper-server with model: $MODEL_NAME"
  66. # Check if model exists
  67. if [ ! -f "$MODEL_PATH" ]; then
  68. log "Error: Model $MODEL_NAME not found at $MODEL_PATH"
  69. log "Available models:"
  70. ls -1 "$WHISPER_DIR/models/" 2>/dev/null | grep "^ggml-.*\.bin$" >> "$STARTUP_LOG" || true
  71. # Try to find any available model as fallback
  72. FALLBACK_MODEL=$(ls -1 "$WHISPER_DIR/models/" 2>/dev/null | grep "^ggml-.*\.bin$" | head -1)
  73. if [ -n "$FALLBACK_MODEL" ]; then
  74. MODEL_PATH="$WHISPER_DIR/models/$FALLBACK_MODEL"
  75. log "Using fallback model: $FALLBACK_MODEL"
  76. else
  77. log "Fatal: No whisper models found"
  78. exit 1
  79. fi
  80. fi
  81. # Port configuration (with environment variable support)
  82. WHISPER_PORT="${VOICEMODE_WHISPER_PORT:-2022}"
  83. # Thread configuration - auto-detect CPU cores if not specified
  84. # Works on macOS, Linux, and WSL
  85. if [ -n "${VOICEMODE_WHISPER_THREADS:-}" ]; then
  86. WHISPER_THREADS="$VOICEMODE_WHISPER_THREADS"
  87. elif [ "$(uname -s)" = "Darwin" ]; then
  88. # macOS - use sysctl
  89. WHISPER_THREADS=$(sysctl -n hw.ncpu 2>/dev/null || echo 4)
  90. else
  91. # Linux/WSL - use nproc
  92. WHISPER_THREADS=$(nproc 2>/dev/null || echo 4)
  93. fi
  94. # Thread capping when CoreML active — commented out pending VM-642 testing
  95. # The whisper.cpp issue #779 suggests high thread counts conflict with CoreML,
  96. # but we haven't confirmed this is needed. Uncomment if VM-642 testing shows it helps.
  97. # See: https://github.com/ggml-org/whisper.cpp/issues/779
  98. # COREML_MODEL_DIR="$WHISPER_DIR/models/ggml-${MODEL_NAME}-encoder.mlmodelc"
  99. # if [ -d "$COREML_MODEL_DIR" ]; then
  100. # if [ "$WHISPER_THREADS" -gt 4 ]; then
  101. # log "CoreML model detected — capping threads at 4 (was $WHISPER_THREADS) to avoid ANE threading conflict"
  102. # WHISPER_THREADS=4
  103. # fi
  104. # fi
  105. log "Using $WHISPER_THREADS threads"
  106. # Determine server binary location
  107. # Check new CMake build location first, then legacy location
  108. if [ -f "$WHISPER_DIR/build/bin/whisper-server" ]; then
  109. SERVER_BIN="$WHISPER_DIR/build/bin/whisper-server"
  110. elif [ -f "$WHISPER_DIR/server" ]; then
  111. SERVER_BIN="$WHISPER_DIR/server"
  112. else
  113. log "Error: whisper-server binary not found"
  114. log "Checked: $WHISPER_DIR/build/bin/whisper-server"
  115. log "Checked: $WHISPER_DIR/server"
  116. exit 1
  117. fi
  118. log "Using binary: $SERVER_BIN"
  119. log "Model path: $MODEL_PATH"
  120. log "Port: $WHISPER_PORT"
  121. # CoreML model path (used by timeout fallback to disable CoreML if server hangs)
  122. COREML_MODEL_DIR="$WHISPER_DIR/models/ggml-${MODEL_NAME}-encoder.mlmodelc"
  123. # Startup timeout configuration
  124. STARTUP_TIMEOUT="${VOICEMODE_WHISPER_STARTUP_TIMEOUT:-120}"
  125. HEALTH_URL="http://127.0.0.1:${WHISPER_PORT}/health"
  126. # Start whisper-server in background to monitor startup
  127. cd "$WHISPER_DIR"
  128. "$SERVER_BIN" \
  129. --host 0.0.0.0 \
  130. --port "$WHISPER_PORT" \
  131. --model "$MODEL_PATH" \
  132. --inference-path /v1/audio/transcriptions \
  133. --threads "$WHISPER_THREADS" \
  134. --convert &
  135. SERVER_PID=$!
  136. log "Started whisper-server (PID: $SERVER_PID), waiting for health check..."
  137. # Poll health endpoint until ready or timeout
  138. ELAPSED=0
  139. while [ "$ELAPSED" -lt "$STARTUP_TIMEOUT" ]; do
  140. # Check if process is still alive
  141. if ! kill -0 "$SERVER_PID" 2>/dev/null; then
  142. log "whisper-server process exited unexpectedly"
  143. wait "$SERVER_PID" 2>/dev/null || true
  144. exit 1
  145. fi
  146. # Check if health endpoint responds
  147. if curl -sf "$HEALTH_URL" >/dev/null 2>&1; then
  148. log "whisper-server is ready (took ${ELAPSED}s)"
  149. # Server is healthy — wait for it (keeps this script as the parent)
  150. wait "$SERVER_PID"
  151. exit $?
  152. fi
  153. sleep 2
  154. ELAPSED=$((ELAPSED + 2))
  155. done
  156. # Timeout reached — server hung during initialization (likely CoreML ANE compilation)
  157. log "WARNING: whisper-server failed to start within ${STARTUP_TIMEOUT}s"
  158. # Kill the hung process
  159. kill "$SERVER_PID" 2>/dev/null || true
  160. sleep 1
  161. kill -9 "$SERVER_PID" 2>/dev/null || true
  162. wait "$SERVER_PID" 2>/dev/null || true
  163. # Disable CoreML model to prevent future hangs
  164. if [ -d "$COREML_MODEL_DIR" ]; then
  165. log "Disabling CoreML model to prevent ANE compilation hang: $COREML_MODEL_DIR -> ${COREML_MODEL_DIR}.disabled"
  166. mv "$COREML_MODEL_DIR" "${COREML_MODEL_DIR}.disabled"
  167. # Reset thread count since CoreML is now disabled
  168. if [ "$(uname -s)" = "Darwin" ]; then
  169. WHISPER_THREADS=$(sysctl -n hw.ncpu 2>/dev/null || echo 4)
  170. else
  171. WHISPER_THREADS=$(nproc 2>/dev/null || echo 4)
  172. fi
  173. log "Restarting without CoreML (Metal acceleration only), threads: $WHISPER_THREADS"
  174. else
  175. log "No CoreML model to disable — restarting with same configuration"
  176. fi
  177. # Restart whisper-server (exec replaces this script process)
  178. exec "$SERVER_BIN" \
  179. --host 0.0.0.0 \
  180. --port "$WHISPER_PORT" \
  181. --model "$MODEL_PATH" \
  182. --inference-path /v1/audio/transcriptions \
  183. --threads "$WHISPER_THREADS" \
  184. --convert

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.