Mercurial
comparison dictation/config.py @ 282:6bd4a3990696 default tip
Add cross-platform canvas orchestration and typed composer
Enable native ARM dependencies, macOS Copilot orchestration, portable service supervision, CPU dictation, and a shared N-key speak-or-type composer.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: f68442b1-fa8f-46a0-9689-81710613bbd4
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Thu, 20 Aug 2026 20:45:25 -0700 |
| parents | 49e9e591c9bb |
| children |
comparison
equal
deleted
inserted
replaced
| 281:c57149ad216e | 282:6bd4a3990696 |
|---|---|
| 1 from __future__ import annotations | 1 from __future__ import annotations |
| 2 | 2 |
| 3 from dataclasses import dataclass | 3 from dataclasses import dataclass |
| 4 import os | 4 import os |
| 5 from pathlib import Path | 5 from pathlib import Path |
| 6 import sys | |
| 6 | 7 |
| 7 | 8 |
| 8 MODEL_REPOSITORY = "Systran/faster-whisper-small" | 9 MODEL_REPOSITORY = "Systran/faster-whisper-small" |
| 9 MODEL_REVISION = "536b0662742c02347bc0e980a01041f333bce120" | 10 MODEL_REVISION = "536b0662742c02347bc0e980a01041f333bce120" |
| 10 | 11 |
| 38 @dataclass(frozen=True) | 39 @dataclass(frozen=True) |
| 39 class DictationConfig: | 40 class DictationConfig: |
| 40 host: str | 41 host: str |
| 41 port: int | 42 port: int |
| 42 model_dir: Path | 43 model_dir: Path |
| 44 device: str | |
| 43 compute_type: str | 45 compute_type: str |
| 44 max_sessions: int | 46 max_sessions: int |
| 45 partial_interval_ms: int | 47 partial_interval_ms: int |
| 46 silence_ms: int | 48 silence_ms: int |
| 47 max_utterance_seconds: int | 49 max_utterance_seconds: int |
| 59 os.environ.get( | 61 os.environ.get( |
| 60 "DICTATION_MODEL_DIR", | 62 "DICTATION_MODEL_DIR", |
| 61 str(cache_root / "zenbu" / "faster-whisper-small"), | 63 str(cache_root / "zenbu" / "faster-whisper-small"), |
| 62 ) | 64 ) |
| 63 ).expanduser() | 65 ).expanduser() |
| 66 device = os.environ.get( | |
| 67 "DICTATION_DEVICE", | |
| 68 "cpu" if sys.platform == "darwin" else "cuda", | |
| 69 ) | |
| 70 if device not in {"cpu", "cuda"}: | |
| 71 raise ValueError("DICTATION_DEVICE must be cpu or cuda") | |
| 64 compute_type = os.environ.get( | 72 compute_type = os.environ.get( |
| 65 "DICTATION_COMPUTE_TYPE", | 73 "DICTATION_COMPUTE_TYPE", |
| 66 "int8_float16", | 74 "int8" if device == "cpu" else "int8_float16", |
| 67 ) | 75 ) |
| 68 if compute_type not in { | 76 if compute_type not in { |
| 69 "float16", | 77 "float16", |
| 70 "int8_float16", | 78 "int8_float16", |
| 71 "int8", | 79 "int8", |
| 78 raise ValueError("DICTATION_HOST must not be empty") | 86 raise ValueError("DICTATION_HOST must not be empty") |
| 79 return cls( | 87 return cls( |
| 80 host=host, | 88 host=host, |
| 81 port=_integer("DICTATION_PORT", 8090, 1, 65535), | 89 port=_integer("DICTATION_PORT", 8090, 1, 65535), |
| 82 model_dir=model_dir, | 90 model_dir=model_dir, |
| 91 device=device, | |
| 83 compute_type=compute_type, | 92 compute_type=compute_type, |
| 84 max_sessions=_integer("DICTATION_MAX_SESSIONS", 1, 1, 8), | 93 max_sessions=_integer("DICTATION_MAX_SESSIONS", 1, 1, 8), |
| 85 partial_interval_ms=_integer( | 94 partial_interval_ms=_integer( |
| 86 "DICTATION_PARTIAL_INTERVAL_MS", | 95 "DICTATION_PARTIAL_INTERVAL_MS", |
| 87 500, | 96 500, |