Files
voculinux/setup.py
T
Jatin K MalikandGitHub 917510d3f4 feat: Enhance Whisper Support & Improve Settings UI (#38)
* feat: Implement comprehensive Whisper speech recognition support

🎯 Complete Whisper Implementation:
- Proper model size validation and mapping (small->base, medium->small, large->medium)
- GPU/CPU device detection and automatic model placement
- Efficient in-memory audio processing (no temporary files)
- Custom model cache directory for organized storage
- Enhanced error handling with detailed logging
- Optimized transcription parameters for better accuracy

🔧 Technical Improvements:
- Replace temporary file approach with direct tensor processing
- Add torch.no_grad() context for efficient inference
- Implement proper audio normalization and padding
- Add comprehensive error handling and recovery
- Support for both CPU and CUDA acceleration

📦 Installation Integration:
- Add --with-whisper flag to installation script
- Update setup.py with correct openai-whisper dependencies
- Include torch and torchaudio in whisper extras
- Automatic and manual installation options

🧪 Testing & Validation:
- Add comprehensive test suite for Whisper functionality
- Test model size mapping, initialization, and transcription
- Mock-based testing for environments without Whisper installed
- Integration with existing test infrastructure

💡 Performance Optimizations:
- Efficient audio buffer processing without file I/O
- GPU acceleration when available
- Optimized Whisper parameters for real-time usage
- Memory-efficient model loading and caching

🔄 Backward Compatibility:
- Maintains full compatibility with existing VOSK implementation
- Graceful fallback when Whisper dependencies are missing
- No breaking changes to existing API

This implementation provides a production-ready Whisper integration
that significantly improves transcription accuracy while maintaining
the performance characteristics needed for real-time voice dictation.

* feat: Add comprehensive Whisper installation support and error handling

🎯 Enhanced User Experience:
- Add intelligent Whisper import error detection in settings dialog
- Show helpful installation instructions when Whisper is missing
- Automatically revert to VOSK when Whisper selection fails
- Provide multiple installation methods and troubleshooting tips

📋 New Installation Helper:
- Create install-whisper.sh script for dedicated Whisper installation
- Support multiple installation methods (standard, trusted hosts, break-system-packages)
- Comprehensive error handling and fallback options
- Clear instructions for SSL issues and alternative approaches

🔧 Improved Error Handling:
- Detect Whisper import errors specifically in settings dialog
- Show user-friendly dialog with installation instructions
- Graceful fallback to VOSK when Whisper unavailable
- Detailed logging for troubleshooting

💡 User Guidance:
- Step-by-step installation instructions in error dialog
- Multiple installation options for different environments
- Clear explanation of disk space and time requirements
- Troubleshooting tips for common SSL issues

🛠️ Technical Features:
- Automatic virtual environment detection
- Installation verification and model listing
- SSL issue detection and workarounds
- Comprehensive error reporting and recovery

This addresses the immediate issue where users get cryptic errors
when trying to use Whisper without proper installation, providing
clear guidance and multiple solutions for different scenarios.

* feat: Enhance Whisper support and improve Settings UI

## Whisper Implementation Fixes
- Fix Whisper transcription by removing unnecessary audio padding
- Fix API usage: pass numpy array directly instead of torch tensor
- Remove confusing model size remapping (users select exact model names)
- Add fp16=False for CPU to prevent warnings
- Fix missing 'import torch' in install-whisper.sh verification

## Audio System Improvements
- Add ALSA error handler to suppress noisy warnings
- Process remaining audio buffer when stopping recognition (fixes test button)

## Settings Dialog UI Enhancements
- Add model metadata display (download status, size, recommendations)
- Show ✓ for downloaded models, ↓ for pending downloads, ★ for recommended
- Add system-based model recommendations (based on RAM/GPU)
- Implement auto-apply settings on change (remove Apply button)
- Fix VOSK settings visibility when Whisper is selected
- Add VOSK model info panel with same features as Whisper
- Fix test recognition to show results in dialog instead of injecting text
- Fix race condition in test result display

## Startup Improvements
- Load saved config on startup (engine/model now persists correctly)
- Settings are remembered between app restarts

## Code Quality
- Add get_text_callbacks/set_text_callbacks methods for test isolation
- Update tests with proper mocking
2025-12-28 13:06:51 -08:00

147 lines
5.3 KiB
Python

#!/usr/bin/env python3
"""
Vocalinux - A seamless voice dictation system for Linux
"""
import os
import sys
import platform
from setuptools import find_packages, setup
# Check Python version
MIN_PYTHON_VERSION = (3, 8)
if sys.version_info < MIN_PYTHON_VERSION:
sys.exit(f"Error: Vocalinux requires Python {MIN_PYTHON_VERSION[0]}.{MIN_PYTHON_VERSION[1]} or higher")
# This package requires several system dependencies that must be installed manually:
# For PyAudio: portaudio19-dev (on Ubuntu/Debian)
# For PyGObject: libgirepository1.0-dev, libcairo2-dev, pkg-config, python3-dev
# Get long description from README if available
long_description = ""
if os.path.exists("README.md"):
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
# Get version from version file or default to 0.1.0
version = "0.1.0"
if os.path.exists("src/vocalinux/version.py"):
with open("src/vocalinux/version.py", "r", encoding="utf-8") as f:
exec(f.read())
version = locals().get("__version__", "0.1.0")
# Platform-specific dependencies
platform_dependencies = []
if platform.system() == "Linux":
platform_dependencies.extend([
"python-xlib", # For keyboard shortcut handling in X11
"PyGObject", # For GTK UI
])
setup(
name="vocalinux",
version=version,
description="A seamless voice dictation system for Linux",
long_description=long_description,
long_description_content_type="text/markdown",
author="Jatin K Malik",
author_email="jatinkrmalik@gmail.com",
url="https://github.com/jatinkrmalik/vocalinux",
project_urls={
"Bug Tracker": "https://github.com/jatinkrmalik/vocalinux/issues",
"Documentation": "https://github.com/jatinkrmalik/vocalinux/tree/main/docs",
"Source Code": "https://github.com/jatinkrmalik/vocalinux",
},
packages=find_packages(where="src"),
package_dir={"": "src"},
install_requires=[
"vosk>=0.3.45", # For VOSK API speech recognition
"pydub>=0.25.1", # For audio processing
"pynput>=1.7.6", # For keyboard/mouse events
"requests>=2.28.0", # For downloading models
"tqdm>=4.64.0", # For progress bars during downloads
"numpy>=1.22.0", # For numerical operations
"pyaudio>=0.2.13", # For audio input/output
] + platform_dependencies,
extras_require={
"whisper": [
"openai-whisper>=20231117",
"torch>=2.0.0",
"torchaudio>=2.0.0",
], # Optional Whisper AI support
"dev": [
"pytest>=7.0.0",
"pytest-cov>=4.0.0", # For coverage testing
"pytest-mock>=3.10.0", # For mocking in tests
"black>=23.0.0", # For code formatting
"isort>=5.12.0", # For import sorting
"flake8>=6.0.0", # For linting
"pre-commit>=3.0.0", # For pre-commit hooks
],
"docs": [
"sphinx>=6.0.0",
"sphinx-rtd-theme>=1.2.0",
],
},
entry_points={
"console_scripts": [
"vocalinux=vocalinux.main:main",
],
"gui_scripts": [
"vocalinux-gui=vocalinux.main:main",
],
},
# Include custom application icons and sounds in the package
data_files=[
# System-wide icons for desktop integration
(
"share/icons/hicolor/scalable/apps",
[
"resources/icons/scalable/vocalinux.svg",
"resources/icons/scalable/vocalinux-microphone.svg",
"resources/icons/scalable/vocalinux-microphone-off.svg",
"resources/icons/scalable/vocalinux-microphone-process.svg",
],
),
# Desktop file for application launcher
("share/applications", ["vocalinux.desktop"]),
# Install resources inside the package share directory for runtime discovery
(
"share/vocalinux/resources/icons/scalable",
[
"resources/icons/scalable/vocalinux.svg",
"resources/icons/scalable/vocalinux-microphone.svg",
"resources/icons/scalable/vocalinux-microphone-off.svg",
"resources/icons/scalable/vocalinux-microphone-process.svg",
],
),
(
"share/vocalinux/resources/sounds",
[
"resources/sounds/start_recording.wav",
"resources/sounds/stop_recording.wav",
"resources/sounds/error.wav",
],
),
],
include_package_data=True,
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: X11 Applications :: GTK",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Desktop Environment :: Gnome",
"Topic :: Multimedia :: Sound/Audio :: Speech",
"Topic :: Text Processing",
"Topic :: Utilities",
],
python_requires=">=3.8", # Minimum Python version
zip_safe=False, # Required for PyGObject applications
)