Jatin K MalikandGitHub f417c28efa fix(threading): harden thread safety for Remote API, IBus, and text injection (#452)
* fix(threading): harden thread safety for HTTP session, IBus, and text injector

Four critical thread-safety fixes identified during PR #335 review:

1. Remote API: snapshot _http_session under _model_lock in
   _process_audio_buffer() to prevent use-after-close races with
   reconfigure/reinitialize. Pass session as explicit parameter to
   _transcribe_with_remote_api, _try_whispercpp_server_api, and
   _try_openai_api. Call _http_session.close() before setting to None
   in reinitialize_after_resume(). Remove blocking connection probe
   from _init_remote_api() (settings dialog has a Test Connection
   button for that).

2. Text injector: extend _state_lock to protect stop() (writes
   _ibus_injector=None and _ibus_ready=False) and inject_text() reads
   of environment/_ibus_injector. Also guard environment/wayland_tool
   writes in _switch_to_non_ibus_backend() and WAYLAND_XDOTOOL fallback
   in inject_text's exception handler.

3. IBus engine: snapshot cls._active_instance into a local variable
   before the do_inject closure in the socket server handler, closing
   the TOCTOU race with do_destroy().

4. Test suspend handler: add _http_session=None to _make_manager()
   fixture so reinitialize_after_resume() finds the attribute.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

* test(threading): update tests for thread-safety changes

- test_recognition_manager_remote_api: pass session param to
  _transcribe_with_remote_api, _try_openai_api, and
  _try_whispercpp_server_api. Update assert_called_once_with patterns
  for the new session argument. Simplify init tests that no longer
  need connection probe mocks (removed from _init_remote_api).
- test_text_injector: add threading.Lock to all TextInjector.__new__()
  instances so _state_lock is available for lock-guarded methods.
- test_suspend_handler: add _http_session=None to _make_manager()
  fixture so reinitialize_after_resume() finds the attribute.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

* test(threading): improve coverage for thread-safety fixes

Add tests for _process_audio_buffer remote API dispatch (session snapshot
under lock, early return when session is None) and reinitialize_after_resume
session close. Mark server_thread as pragma: no cover (blocked by conftest
to prevent CI hangs).
2026-06-06 16:26:28 -07:00
2025-05-25 23:20:08 -05:00
2026-01-20 00:00:28 -08:00

Vocalinux

Voice-to-text for Linux, finally done right!

Status: Beta GitHub release License: GPL v3

Vocalinux CI Platform: Linux Python 3.9+ Made with GTK codecov

GitHub stars GitHub forks GitHub watchers Last commit Commit activity Contributions welcome GitHub issues

Vocalinux Users

Linux has always punched above its weight, except when it comes to voice typing. Vocalinux fixes that.

It's a free, GPLv3-licensed desktop app that lets you dictate text into any application, on X11 or Wayland, using fully offline speech recognition. Pick from three engines (whisper.cpp, OpenAI Whisper, or VOSK), get automatic GPU acceleration via Vulkan, and control it all with customizable keyboard shortcuts: toggle or push-to-talk.

No internet required. No data leaves your machine. Just speak and type.

📚 What's New in v0.11.0-beta

🎉 Release: Advanced Settings tab with anti-hallucination parameters, IBus/recognition hardening, and distro compatibility improvements.

🚀 Highlights

Feature Description
⚙️ Advanced Settings Tab New Advanced tab with whisper.cpp anti-hallucination parameters (temperature, no_speech_threshold, etc.)
🔌 IBus Hardening Engine readiness probe at startup, runtime failure recovery, and proper engine destruction on layout switch
🎤 Recognition Reliability Preserve final speech on stop and improved stop-sound playback timing
📦 Distro Compatibility Hardened Debian layer, corrected openSUSE Tumbleweed deps, Python 3.14 support
🔧 Installer Fixes Repair pywhispercpp loading, validate proj configs before local repo mode, reuse existing whispercpp builds

✨ New Features

  • Advanced Settings tab — New tab in Settings dialog exposing whisper.cpp anti-hallucination parameters:
    • Temperature override
    • No-speech threshold
    • Max segment length
    • Other inference-time parameters for fine-tuning recognition behavior

🐛 Bug Fixes

  • IBus: Probe engine readiness at startup with hardened retries (#391)
  • IBus: Handle engine instance destruction on layout switch (#389)
  • IBus: Recover from runtime failures gracefully (#411)
  • Recognition: Preserve final speech when stopping (#401)
  • Recognition: Play stop sound immediately on release (#426) and after audio thread joins (#436)
  • Install: Repair pywhispercpp library loading (#433)
  • Install: Correct openSUSE Tumbleweed dependencies (#420, #418)
  • Install: Harden Debian compatibility layer (#437)
  • Install: Validate pyproject.toml/setup.py before local repo mode (#396)
  • Install: Reuse existing whispercpp builds (#421)
  • Install: Refresh ldconfig after openSUSE typelib install (#438)
  • whisper.cpp: Reduce CPU threads and ensure GPU backend builds in dev mode (#439)
  • Logging: Clean up runtime log noise and cache hardware detection
  • Python 3.14 support: Compatibility fix and lxml>=6.1.0 (#404)

🔧 Improvements

  • Installer refresh — openSUSE fallback handling, Debian compatibility hardening
  • Test coverage — Recognition internals, IBus edge cases, CI notification suppression (#410, #414)
  • Dependency bumps — Next.js security updates (#399, #429), PostCSS (#2753679)
  • PyPI docs — Clarify installation requirements (#423)

✨ Features

  • 🎤 Toggle or Push-to-Talk activation modes
  • ⚡ Real-time transcription with minimal latency
  • 🌎 Universal compatibility across all Linux applications
  • 🔒 100% Offline operation for privacy and reliability
  • 🤖 whisper.cpp by default - High-performance C++ speech recognition
  • 🎮 Universal GPU support - Vulkan acceleration for AMD, Intel, and NVIDIA
  • 🎨 System tray integration with visual status indicators
  • 🚀 Start on login support via XDG autostart (desktop-session startup)
  • 🔊 Pleasant audio feedback - smooth gliding tones, headphone-friendly
  • ⚙️ Graphical settings dialog for easy configuration
  • 📦 3 engine choices - whisper.cpp (default), OpenAI Whisper, or VOSK

📸 Screenshots

Here are some screenshots showcasing Vocalinux in action:

Transcription in Action
Real-time voice-to-text transcription
System Tray
System tray with listening indicator
About View
About view with version info
Log Viewer
Log viewer for debugging
Features Overview
Overview of key features and configuration options with annotations

🚀 Quick Install

Our new interactive installer guides you through setup with intelligent hardware detection:

curl -fsSL raw.githubusercontent.com/jatinkrmalik/vocalinux/main/install.sh -o /tmp/vl.sh && bash /tmp/vl.sh

Choose your engine:

  1. whisper.cpp ⭐ (Recommended) - Fast, works with any GPU via Vulkan
  2. Whisper (OpenAI) - PyTorch-based, NVIDIA GPU only
  3. VOSK - Lightweight, works on older systems

The installer will:

  • Auto-detect your hardware (GPU, RAM, Vulkan support)
  • Recommend the best engine for your system
  • Download the appropriate model (~39MB for whisper.cpp tiny)
  • Install neural VAD support when ONNX Runtime is available
  • Install in ~1-2 minutes (vs 5-10 min with old Whisper)

Note

: Always installs the latest release. For a specific version, check GitHub Releases.

Installation Options

Default (whisper.cpp - recommended):

curl -fsSL raw.githubusercontent.com/jatinkrmalik/vocalinux/main/install.sh -o /tmp/vl.sh && bash /tmp/vl.sh

Fastest installation (~1-2 min), universal GPU support via Vulkan.

Whisper (OpenAI) - if you prefer PyTorch:

curl -fsSL raw.githubusercontent.com/jatinkrmalik/vocalinux/main/install.sh -o /tmp/vl.sh && bash /tmp/vl.sh --engine=whisper

NVIDIA GPU only (~5-10 min, downloads PyTorch + CUDA).

VOSK only - for low-RAM systems:

curl -fsSL raw.githubusercontent.com/jatinkrmalik/vocalinux/main/install.sh -o /tmp/vl.sh && bash /tmp/vl.sh --engine=vosk

Lightweight option (~40MB), works on systems with 4GB RAM.

Alternative: Install from Source

# Clone the repository
git clone https://github.com/jatinkrmalik/vocalinux.git
cd vocalinux

# Run the installer (will prompt for Whisper)
./install.sh

# Or with Whisper support
./install.sh --with-whisper

The installer handles everything: system dependencies, Python environment, speech models, and desktop integration.

🌙 Nightly Releases (Bleeding Edge)

For developers and early adopters who want to test the latest features, check out our GitHub Releases page which includes both beta and nightly builds.

⚠️ Warning: Nightly releases contain the absolute latest code and may be unstable. For production use, we recommend using the latest beta release.

Nightly builds are automatically generated from the main branch every day. They include all merged changes but haven't undergone the same testing as beta releases.

Release Channels:

  • Beta (Recommended) - Tested pre-releases with known features
  • Nightly - Untested bleeding edge with latest commits

After Installation

# If ~/.local/bin is in your PATH (recommended):
vocalinux

# Or activate the virtual environment first:
source ~/.local/bin/activate-vocalinux.sh
vocalinux

# Or run directly:
~/.local/share/vocalinux/venv/bin/vocalinux

Or launch it from your application menu!

📋 Requirements

  • OS: Linux (tested on Ubuntu 22.04+, Debian 11+, Fedora 39+, Arch Linux, openSUSE Tumbleweed)
  • Python: 3.9 or newer
  • Display: X11 or Wayland
  • Hardware: Microphone for voice input

Note: See Distribution Compatibility for distribution-specific information and experimental support for Gentoo, Alpine, Void, Solus, and more.

🎙️ Usage

Voice Dictation

  1. Toggle mode: Double-tap the shortcut key (default Ctrl) to start recording
  2. Speak clearly into your microphone
  3. Toggle mode: Double-tap again (or pause speaking) to stop, or Push-to-Talk mode: release the key to stop

Voice Commands

Command Action
"new line" Inserts a line break
"period" / "full stop" Types a period (.)
"comma" Types a comma (,)
"question mark" Types a question mark (?)
"exclamation mark" Types an exclamation mark (!)
"delete that" Deletes the last sentence
"capitalize" Capitalizes the next word

Command Line Options

vocalinux --help                  # Show all options
vocalinux --debug                 # Enable debug logging
vocalinux --engine whisper_cpp    # Use whisper.cpp engine (default)
vocalinux --engine whisper        # Use OpenAI Whisper engine
vocalinux --engine vosk           # Use VOSK engine
vocalinux --model medium          # Use medium-sized model
vocalinux --wayland               # Force Wayland mode
vocalinux --start-minimized       # Start without first-run modal prompts

Autostart on Login

Vocalinux uses the Linux desktop standard for autostart:

  • Mechanism: XDG autostart desktop entry (vocalinux.desktop)
  • Path: $XDG_CONFIG_HOME/autostart/ or ~/.config/autostart/ (fallback)
  • Launch mode: Starts as a regular user desktop app in your graphical session
  • Not used: No systemd unit/service is created by Vocalinux for autostart

How to enable/disable:

  • First-run welcome dialog
  • Tray menu: Start on Login
  • Settings dialog: Start on Login

Compatibility notes:

  • Works on mainstream desktop environments (GNOME, KDE, Xfce, Cinnamon, MATE, LXQt)
  • On minimal/custom window-manager sessions, an autostart handler may be required (for example DE-specific startup hooks or tools like dex)

⚙️ Configuration

Configuration is stored in ~/.config/vocalinux/config.json:

{
  "speech_recognition": {
    "engine": "whisper_cpp",
    "model_size": "tiny",
    "vad_sensitivity": 3,
    "silence_timeout": 2.0
  }
}

You can also configure settings through the graphical Settings dialog (right-click the tray icon).

Neural Voice Activity Detection

Vocalinux ships with a Silero VAD model and uses it automatically when onnxruntime is available. The official installer attempts to install this support automatically. Without it, recording falls back to the simpler amplitude-threshold VAD.

For manual or PyPI installs, enable neural VAD with:

pip install "vocalinux[vad]"

Restart Vocalinux after install. The Recognition tab in Settings shows which backend is active. The same vad_sensitivity (1-5) works for both -- it's mapped to a Silero probability threshold internally (1 = 0.8, 5 = 0.3).

🔧 Development Setup

# Clone and install in dev mode
git clone https://github.com/jatinkrmalik/vocalinux.git
cd vocalinux
./install.sh --dev

# Activate environment
source venv/bin/activate

# Run tests
pytest

# Run from source with debug
python -m vocalinux.main --debug

📁 Project Structure

vocalinux/
├── src/vocalinux/                 # Main application code
│   ├── speech_recognition/        # Speech recognition engines (VOSK, Whisper, whisper.cpp)
│   │   └── recognition_manager.py # Unified engine interface
│   ├── text_injection/            # Text injection (X11/Wayland)
│   ├── ui/                        # GTK UI components
│   └── utils/                     # Utility functions
│       ├── whispercpp_model_info.py   # whisper.cpp model metadata & hardware detection
│       └── vosk_model_info.py         # VOSK model metadata
├── tests/                         # Test suite
├── scripts/                       # Development utilities
│   └── generate_sounds.py         # Sound generation script
├── resources/                     # Icons and sounds
├── docs/                          # Documentation
└── web/                           # Website source

📖 Documentation

🔊 Sound Customization

Vocalinux uses smooth, pleasant gliding tones for audio feedback:

  • Start: Ascending F4→A4 (0.6s) - positive, uplifting
  • Stop: Descending A4→F4 (0.6s) - resolves completion
  • Error: Lower descending E4→C4 (0.7s) - gentle but noticeable

All sounds use pure sine waves with smoothstep interpolation for buttery smooth pitch transitions - perfect for headphone use!

Regenerate Sounds

To modify or regenerate the notification sounds:

python scripts/generate_sounds.py

This script generates all three sounds using the same smooth glide algorithm. You can edit the frequencies, durations, and amplitudes in the script to customize the sounds to your preference.

🗺️ Roadmap

  • Custom icon design ✅
  • Graphical settings dialog ✅
  • Whisper AI support ✅
  • Multi-language support (FR, DE, RU) ✅
  • whisper.cpp integration (default engine) ✅
  • Vulkan GPU support ✅
  • In-app update mechanism
  • Application-specific commands
  • Debian/Ubuntu package (.deb)
  • Wayland support via IBus ✅
  • Voice command customization

🌐 The Voca Ecosystem

Vocalinux is part of a family of privacy-first, offline voice dictation tools. Same mission, every operating system.

Platform Project Website GitHub Status
🐧 Linux VocaLinux vocalinux.com jatinkrmalik/vocalinux ✅ Beta v0.11.0
🍎 macOS VocaMac vocamac.com jatinkrmalik/vocamac 🚀 Beta
🪟 Windows VocaWin vocawin.com jatinkrmalik/vocawin 📋 Planned

Each platform uses native technologies for the best possible integration, while sharing the same privacy-first philosophy and offline-only architecture.

🤝 Contributing

We welcome contributions! Whether it's bug reports, feature requests, or code contributions, please check out our Contributing Guide.

Contributors

Thanks to everyone who has contributed to Vocalinux! 🙌

⭐ Support

If you find Vocalinux useful, please consider:

  • ⭐ Starring this repository
  • 🐛 Reporting bugs you encounter
  • 📖 Improving documentation
  • 🔀 Contributing code

📜 License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Star Chart

Star History Chart


Made with ❤️ for the Linux community

S
Description
Free, offline voice dictation for Void Linux and niri. Vulkan GPU acceleration, signed xbps repository.
Readme AGPL-3.0
35 MiB
v0.19.1
Latest
2026-11-06 21:18:19 +00:00
Languages
Python 84.5%
TypeScript 8.6%
Shell 5.6%
CSS 0.6%
Just 0.2%
Other 0.4%