-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
59 lines (47 loc) · 1.44 KB
/
config.py
File metadata and controls
59 lines (47 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File: config.py
"""
Centralised, typed configuration constants.
Edit just this file if you need to change locations, limits, etc.
"""
from pathlib import Path
from typing import Final
# Where raw and split recordings are stored
AUDIO_ARCHIVE_DIR: Final[Path] = Path.home() / "audio_archive"
AUDIO_ARCHIVE_DIR.mkdir(parents=True, exist_ok=True)
# Misc. paths
STATE_DIR: Final[Path] = Path.home() / ".whisper_wait"
STATE_DIR.mkdir(parents=True, exist_ok=True)
SESSION_COSTS_FILE: Final[Path] = STATE_DIR / "session_costs.json"
TRANSCRIPTIONS_FILE: Final[Path] = STATE_DIR / "last_transcriptions.txt"
# Recording / upload limits
MAX_DURATION_SEC: Final[int] = 29 # max length per Whisper call
MAX_SIZE_BYTES: Final[int] = 24 * 1024 * 1024 # 24 MB
# Model / hardware defaults
try:
import torch # noqa: F401
_device = "cuda" if torch.cuda.is_available() else "cpu"
except ModuleNotFoundError:
_device = "cpu"
DEVICE: Final[str] = _device
DEFAULT_MODEL: Final[str] = "medium.en"
AVAILABLE_MODELS: Final[list[str]] = [
"tiny",
"tiny.en",
"base",
"base.en",
"small",
"small.en",
"medium",
"medium.en",
"large",
"large-v2",
"large-v3",
]
# Recording parameters
SAMPLE_RATE: Final[int] = 16_000
CHUNK_SIZE: Final[int] = 4096 # frames read from sounddevice each call
# Environment
DOTENV_PATH: Final[Path] = Path(".env")
# UI defaults
DEFAULT_AUTO_COPY: Final[bool] = True
HISTORY_PREVIEW_COUNT: Final[int] = 5