* feat(asr): add Parakeet engine via sherpa-onnx Adds a "parakeet" engine backed by sherpa-onnx, running NVIDIA Parakeet TDT 0.6B int8 models on CPU: v3 (25 European languages, auto-detected) and v2 (English). Output is punctuated and capitalized. On an Intel Core Ultra 7 155H it decodes at about 12x realtime on CPU (RTF 0.08), roughly 8x faster than whisper.cpp large-v3-turbo over the same clips with its Vulkan GPU backend (RTF 0.59). Being a transducer it also has no 30s window to pad, so a short push-to-talk utterance returns in ~0.3s instead of ~2.4s. Follows the existing engine layout: utils/parakeet_model_info.py holds the catalog and the get_model_path / is_model_downloaded / list_downloaded_models / delete_model helpers, while _init_parakeet / _transcribe_with_parakeet / _download_parakeet_model follow the same shape as their whisper.cpp counterparts and reuse _stream_model_download for progress and cancellation. Registered in the engine dispatch, the settings engine/model/language pickers, the model info card, the download prompts, the unused-downloads list and install.sh. Models download to <models_dir>/parakeet/<model>/ via temp files renamed on success; is_model_downloaded requires all four files, so an interrupted download is retried rather than loaded. Requires the new "parakeet" extra (sherpa-onnx). * fix(install): write only the engine key for parakeet The parakeet branch duplicated a full default config.json. ConfigManager deep-merges DEFAULT_CONFIG on load, so every other key was redundant: a config holding only "engine": "parakeet" still resolves parakeet_model_size to v3-european along with the VAD, shortcut and text-injection defaults. * fix(install): keep push-to-talk defaults and switch existing configs Writing only the engine key left config.json without a shortcuts section, which _migrate_shortcuts_config reads as a pre-push-to-talk upgrade and pins back to ctrl+ctrl/toggle - contradicting the installer's own "Hold Right Alt while you speak" message. Seed that section too. Point the config at parakeet with set_configured_engine rather than only on first create, so --engine=parakeet also switches a machine that already has a config.json, and give print_welcome_message a parakeet arm so the summary is not blank. The interactive picker overwrites SELECTED_ENGINE, so document the flag combination that reaches this branch. * fix(asr): pin Parakeet bundles and report one progress bar Pin each bundle to a Hugging Face commit instead of resolve/main, so a file replaced upstream cannot change what an install downloads. This is the same approach whispercpp_model_info takes with its pinned revision. Remap each file's progress into its slice of the bundle. The four files were reported through the single-file downloader independently, so the fraction ran to 1.0 and restarted four times; it now advances once and names the file being fetched. * fix(asr): reject a truncated Parakeet download _stream_model_download only rejects an empty body, so a truncated but nonempty response was renamed into the model directory and then reported as installed, because is_model_downloaded checks existence. Record the byte size of each file at the pinned revision and check it before the rename, the same order whisper.cpp verifies its digest in. A short file is a truncated transfer rather than an upstream change, since the revision is pinned, so it raises and the temp file is removed. * style(asr): annotate the Parakeet model catalog mypy inferred the catalog values as object, so reading file_sizes out of an entry raised attr-defined and no-any-return under `just typecheck`. * fix(asr): pin Parakeet digests in model_checksums.txt AGENTS.md requires every speech model to be verified against a pinned digest before install, failing closed on an unpinned one. Parakeet was checking only the byte size. Teach scripts/generate-model-checksums.py to emit Parakeet entries: the ONNX files are LFS so Hugging Face publishes their sha256, and tokens.txt is hashed from the downloaded bytes the way VOSK archives are. Several bundles ship the same file names, so a key carries the model name. _download_parakeet_model now calls verify_model_file before the rename and catches ChecksumError alongside the other download failures, matching the whisper.cpp downloader. * fix(asr): verify on-disk Parakeet models before load Existing bundle files were trusted by path alone, so a leftover or copied-in tree could reach sherpa-onnx unchecked. Hash each file against its pin on download skip and on init, and cover the Parakeet pins in CI. * fix(ui): hide Parakeet language picker that ignores the setting Parakeet language coverage is the model choice, not a catalog language. Hide the picker and persist auto so Settings does not write a lying value. * fix(asr): normalize Parakeet language to auto at startup CLI --language and stale saved languages still reached SpeechRecognitionManager even though Parakeet ignores catalog language. Force auto on the shared helper used by main and the manager so stored settings stay honest. * fix(ui): restore language after leaving Parakeet Remember the prior Whisper/cpp language across a Parakeet visit so switching back does not leave recognition stuck on auto. Keep Parakeet forced to auto and the picker hidden. Also satisfy black on the startup normalizer path. * fix(ui): keep language memory across Vosk fallback Vosk's unsupported-language en-us coercion was writing into _last_non_parakeet_language, so Whisper→Parakeet→Vosk→Whisper restored en-us instead of the user's Greek (or other) preference. Remember the pre-coercion catalog language and prefer it when leaving Vosk. * fix(ui): keep language memory when entering Parakeet from Vosk Vosk's coerced en-us fallback was still written into _last_non_parakeet_language on Parakeet entry, so Vosk→Parakeet→Whisper restored en-us instead of the pre-coercion preference (Greek or auto). Share one coerced-fallback predicate across entry, leave-Vosk, and language sync, and cover those paths with regression tests. * fix(tests): set initializing flags false on language-change stubs Plain Mock attributes are truthy and were short-circuiting the handler. --------- Co-authored-by: Alex Thunder <AlexThunder@gmail.com>
207 lines
5.4 KiB
TOML
207 lines
5.4 KiB
TOML
[build-system]
|
|
# >=77 for the SPDX license string below. No upper bound: Arch extra
|
|
# python-setuptools is 84, and the AUR PKGBUILD builds with --no-isolation.
|
|
requires = ["setuptools>=77"]
|
|
build-backend = "setuptools.build_meta"
|
|
|
|
[project]
|
|
name = "vocalinux"
|
|
dynamic = ["version"]
|
|
description = "A seamless voice dictation system for Linux"
|
|
readme = "README.md"
|
|
license = "AGPL-3.0-only"
|
|
license-files = ["LICENSE"]
|
|
authors = [
|
|
{name = "Jatin K Malik", email = "jatinkrmalik@gmail.com"}
|
|
]
|
|
maintainers = [
|
|
{name = "Jatin K Malik", email = "jatinkrmalik@gmail.com"}
|
|
]
|
|
requires-python = ">=3.11"
|
|
keywords = [
|
|
"voice", "dictation", "speech", "recognition",
|
|
"linux", "accessibility", "voice-typing", "speech-to-text"
|
|
]
|
|
classifiers = [
|
|
"Development Status :: 5 - Production/Stable",
|
|
"Environment :: X11 Applications :: GTK",
|
|
"Intended Audience :: End Users/Desktop",
|
|
"Operating System :: POSIX :: Linux",
|
|
"Programming Language :: Python :: 3",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Programming Language :: Python :: 3.13",
|
|
"Programming Language :: Python :: 3.14",
|
|
"Topic :: Desktop Environment :: Gnome",
|
|
"Topic :: Multimedia :: Sound/Audio :: Speech",
|
|
"Topic :: Text Processing",
|
|
"Topic :: Utilities",
|
|
]
|
|
dependencies = [
|
|
"pywhispercpp>=1.5.0,<2",
|
|
"pynput>=1.7.6,<2",
|
|
"evdev>=1.6.0,<2; sys_platform == 'linux'",
|
|
"requests>=2.28.0",
|
|
"numpy>=1.22.0,<3",
|
|
"pyaudio>=0.2.13",
|
|
"PyGObject; sys_platform == 'linux'",
|
|
"psutil>=5.9.0,<8",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
vosk = [
|
|
"vosk>=0.3.45",
|
|
]
|
|
whisper = [
|
|
"openai-whisper>=20231117",
|
|
"torch>=2.0.0",
|
|
"torchaudio>=2.0.0",
|
|
]
|
|
parakeet = [
|
|
"sherpa-onnx>=1.12.0",
|
|
]
|
|
vad = [
|
|
"onnxruntime>=1.16.0",
|
|
]
|
|
dev = [
|
|
"pytest>=7.0.0",
|
|
"pytest-cov>=4.0.0",
|
|
"pytest-mock>=3.10.0",
|
|
"pytest-timeout>=2.1.0",
|
|
"pre-commit>=3.0.0",
|
|
"mypy>=1.0.0",
|
|
]
|
|
docs = [
|
|
"sphinx>=6.0.0",
|
|
"sphinx-rtd-theme>=1.2.0",
|
|
]
|
|
|
|
# Formatters and linters, deliberately outside the `dev` extra: `uv sync
|
|
# --only-group lint` installs them without the project, so the lint job needs
|
|
# no portaudio/girepository headers to build pyaudio and PyGObject.
|
|
[dependency-groups]
|
|
lint = [
|
|
"black>=23.0.0",
|
|
"isort>=5.12.0",
|
|
"flake8>=6.0.0",
|
|
]
|
|
|
|
[project.scripts]
|
|
vocalinux = "vocalinux.main:main"
|
|
|
|
[project.gui-scripts]
|
|
vocalinux-gui = "vocalinux.main:main"
|
|
|
|
[project.urls]
|
|
Homepage = "https://github.com/VocaHQ/vocalinux"
|
|
Documentation = "https://github.com/VocaHQ/vocalinux/tree/main/docs"
|
|
Repository = "https://github.com/VocaHQ/vocalinux"
|
|
Issues = "https://github.com/VocaHQ/vocalinux/issues"
|
|
Changelog = "https://github.com/VocaHQ/vocalinux/releases"
|
|
|
|
[tool.uv]
|
|
# Lock/exports are generated with uv; keep the minor pinned so lockfile
|
|
# upgrades are deliberate (see `just lock`).
|
|
required-version = ">=0.12,<0.13"
|
|
|
|
[tool.setuptools]
|
|
# Resource dirs carry no .py files, but setuptools still treats them as packages.
|
|
packages = [
|
|
"vocalinux",
|
|
"vocalinux.resources",
|
|
"vocalinux.resources.icons",
|
|
"vocalinux.resources.icons.scalable",
|
|
"vocalinux.resources.sounds",
|
|
"vocalinux.speech_recognition",
|
|
"vocalinux.speech_recognition.data",
|
|
"vocalinux.text_injection",
|
|
"vocalinux.ui",
|
|
"vocalinux.ui.keyboard_backends",
|
|
"vocalinux.utils",
|
|
]
|
|
package-dir = {"" = "src"}
|
|
|
|
[tool.setuptools.dynamic]
|
|
version = {attr = "vocalinux.version.__version__"}
|
|
|
|
[tool.setuptools.package-data]
|
|
"*" = ["*.svg", "*.wav", "*.onnx"]
|
|
"vocalinux" = ["resources/**/*"]
|
|
"vocalinux.speech_recognition" = ["data/*.onnx", "data/LICENSE"]
|
|
"vocalinux.utils" = ["model_checksums.txt"]
|
|
|
|
[tool.black]
|
|
line-length = 100
|
|
target-version = ['py311', 'py312', 'py313', 'py314']
|
|
include = '\.pyi?$'
|
|
exclude = '''
|
|
/(
|
|
\.git
|
|
| \.hg
|
|
| \.mypy_cache
|
|
| \.tox
|
|
| \.venv
|
|
| venv
|
|
| _build
|
|
| buck-out
|
|
| build
|
|
| dist
|
|
| node_modules
|
|
)/
|
|
'''
|
|
|
|
[tool.isort]
|
|
profile = "black"
|
|
line_length = 100
|
|
skip_gitignore = true
|
|
skip = [".git", "venv", "node_modules", "build", "dist"]
|
|
|
|
[tool.pytest.ini_options]
|
|
minversion = "7.0"
|
|
addopts = "-ra -q --strict-markers --timeout=10 --timeout_method=thread"
|
|
testpaths = ["tests"]
|
|
python_files = ["test_*.py"]
|
|
python_functions = ["test_*"]
|
|
markers = [
|
|
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
|
"integration: marks tests as integration tests",
|
|
"audio: marks tests that require audio hardware",
|
|
]
|
|
|
|
[tool.coverage.run]
|
|
source = ["src"]
|
|
branch = true
|
|
omit = [
|
|
"*/tests/*",
|
|
"*/__pycache__/*",
|
|
# GTK dialog files are untestable without a real GTK environment
|
|
"*/settings_dialog.py",
|
|
"*/logging_dialog.py",
|
|
]
|
|
|
|
[tool.coverage.report]
|
|
exclude_lines = [
|
|
"pragma: no cover",
|
|
"def __repr__",
|
|
"raise NotImplementedError",
|
|
"if TYPE_CHECKING:",
|
|
"if __name__ == .__main__.:",
|
|
]
|
|
show_missing = true
|
|
|
|
[tool.mypy]
|
|
# Target the supported floor so typechecking covers what requires-python promises.
|
|
python_version = "3.11"
|
|
warn_return_any = true
|
|
warn_unused_configs = true
|
|
ignore_missing_imports = true
|
|
exclude = ["venv", "build", "dist", "node_modules"]
|
|
|
|
# numpy 2.x ships stubs written in 3.12 syntax, which a 3.11 target cannot parse.
|
|
# We only pass arrays through, so skipping the stubs costs little compared to
|
|
# type-checking against the Python version we actually promise to support.
|
|
[[tool.mypy.overrides]]
|
|
module = ["numpy", "numpy.*"]
|
|
follow_imports = "skip"
|
|
follow_imports_for_stubs = true
|