Skip to content

Conversation

@brhacket
Copy link

@brhacket brhacket commented Jan 10, 2026

Script info

  • Script name: smarter_tts.py
  • Version: 1.6
  • Requirements: speech-dispatcher (requires spd-say binary in PATH)
  • Min WeeChat version:
  • Script tags: tts, sound, audio, accessibility, speech

Description

A zero-latency, thread-safe Text-to-Speech integration using the system's speech-dispatcher.

Why this is needed (vs existing tts.py):
This script is a modern architectural alternative to the existing tts.py.

  1. Threading vs Process Hook: Unlike tts.py which spawns a new process for every message (causing UI freezes on high load), this script uses a persistent background thread and a FIFO queue.
  2. Standardization: It targets the Linux standard speech-dispatcher rather than hardcoding specific binary flags for espeak or festival.
  3. Smart Logic: It includes "Burst Merging" (combining rapid messages from the same user) and "Nick Humanization" (cleaning up nicknames for phonetic pronunciation) which are not present in older scripts.

Key Features:

  • Auto-Discovery: Automatically scans the system to find sound files for notifications on any distro (Fedora, Arch, Debian, etc).
  • Focus Mode: Only reads the active buffer by default, but allows locking to specific channels via /listento.
  • Background Alerts: Plays a sound and announces channel names for background highlights without reading private text.

Checklist (new script)

  • Single commit, single file added
  • Commit message: New script smarter_tts.py: Zero-latency TTS integration
  • No similar script already exists
  • Name: max 32 chars, only lower case letters, digits and underscores
  • Unique name, does not already exist in repository
  • No shebang on the first line
  • Comment in script with name/pseudo, e-mail and license using SPDX tags (see Contributing guide)
  • Only English in code/comments
  • Pure WeeChat API used, no extra API
  • Function hook_url, hook_process or hook_process_hashtable is used for any blocking call
    • (Note: Script uses standard python threading for the audio queue to ensure zero-latency continuity without blocking the main loop, utilizing hook_timer to safely update UI from the main thread).
  • For Python script: works with Python 3 (Python 2 support is optional)
  • Score 100 / 100 displayed by weechat-script-lint

@brhacket brhacket changed the title New script tts_weechat_by_brhacket.py: Zero-latency TTS integration smarter_tts.py Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant