-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
131 lines (113 loc) · 5.32 KB
/
Copy pathconfig.py
File metadata and controls
131 lines (113 loc) · 5.32 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env python3
"""Configuration constants and paths for Homie voice assistant."""
import os
from dotenv import load_dotenv
# Load environment variables from .env
load_dotenv()
# =============================
# Cloud Service Configuration (True = use cloud, False = use local)
# =============================
USE_CLOUD_STT = True # Speech-to-Text: False = Whisper local, True = OpenAI Whisper API
USE_CLOUD_LLM = True # LLM: False = llama.cpp local, True = OpenAI API
USE_CLOUD_TTS = True # Text-to-Speech: False = Piper local, True = OpenAI TTS
# =============================
# OpenAI API Configuration
# =============================
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "")
OPENAI_STT_MODEL = "gpt-4o-mini-transcribe" # Latest: gpt-4o-mini-transcribe for cloud STT
OPENAI_LLM_MODEL = "gpt-5.4-mini" # Latest: gpt-5.4-mini for fast, efficient cloud LLM
OPENAI_TTS_MODEL = "gpt-4o-mini-tts" # Latest: gpt-4o-mini-tts for cloud TTS
OPENAI_TTS_VOICE = "echo" # Options: alloy, echo, fable, onyx, nova, shimmer
# =============================
# Audio Configuration
# =============================
STT_LANGUAGE = "nl" # Language code for STT: "nl" = Dutch, "en" = English
RATE = 16000
FRAME_MS = 30
FRAME_SIZE = int(RATE * FRAME_MS / 1000) # 480 samples
RESPEAKER_INDEX = 0 # Index from your logs
VAD_MODE = 3 # 0 (most sensitive) to 3 (least sensitive)
SILENCE_TIMEOUT = 2.0 # seconds of silence to stop listening
MAX_LISTENING_TIME = 20.0 # seconds
ROLLBACK_BUFFER_SIZE = int(1.0 * RATE / FRAME_SIZE) # 3 seconds of frames to keep as history
SILENCE_RMS_THRESHOLD = 0.45 # lower values treat quieter speech as active
# =============================
# Wake Word Configuration
# =============================
WAKE_WORD = "hey homie"
# =============================
# Path Configuration
# =============================
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
MODEL_DIR = os.path.join(BASE_DIR, "models")
# =============================
# Vosk Model (for wake word)
# =============================
VOSK_NAME = "vosk-model-small-en-us-0.15"
VOSK_PATH = os.path.join(MODEL_DIR, VOSK_NAME)
VOSK_URL = f"https://alphacephei.com/vosk/models/{VOSK_NAME}.zip"
# =============================
# Whisper Model (for command transcription)
# =============================
WHISPER_MODEL_SIZE = "base" # Options: "tiny", "base", "small", "medium", "large"
# Use "tiny" or "base" for faster transcription (lower accuracy)
# Use "small" for balanced speed/accuracy (default)
# =============================
# Piper TTS
# =============================
PIPER_DIR = os.path.join(MODEL_DIR, "piper")
PIPER_VOICE_EN = os.path.join(PIPER_DIR, "en_US-amy-medium.onnx")
PIPER_VOICE_NL = os.path.join(PIPER_DIR, "nl_NL-mls-medium.onnx")
PIPER_VOICE_DEFAULT = PIPER_VOICE_EN
PIPER_SPEECH_SPEED = 1.2 # 1.0 = normal speed, >1.0 is faster
OPENAI_TTS_SPEED = 1.2
TTS_CHUNK_MAX_CHARS = 420
TTS_PREFETCH_CHUNKS = 2
TTS_CACHE_DIR = os.path.join(BASE_DIR, ".tts_cache")
TOOL_SPOKEN_PROMPTS = {
"search_wikipedia": "Ik zoek dat even voor je op.",
"search_web": "Ik kijk dat meteen online na.",
"spotify_play": "Ik zet dat meteen voor je op.",
"get_weather": "Ik kijk even naar het weer.",
"set_reminder": "Ik regel dat meteen voor je.",
"control_device": "Ik doe dat meteen voor je.",
}
# =============================
# LLM (llama.cpp)
# =============================
LLAMA_SERVER_BIN = os.path.expanduser("~/llama.cpp/build/bin/llama-server")
# LLM_NAME = "phi-4-mini-instruct.Q4_K_M.gguf"
LLM_NAME = "Qwen3-1.7B-Q4_K_M.gguf"
LLM_PATH = os.path.join(MODEL_DIR, LLM_NAME)
# Large model for long answers
LLM_LONG_NAME = "Qwen3-4B-Instruct-2507-Q4_K_M.gguf"
LLM_LONG_PATH = os.path.join(MODEL_DIR, LLM_LONG_NAME)
LLM_LONG_PORT = 8081 # Different port for the large model
LLM_LONG_PROCESS = None # Will be set when server starts
# LLM_URL = "https://huggingface.co/TheBloke/phi-2-GGUF/resolve/main/phi-2.Q4_K_M.gguf"
# LLM_URL = "https://huggingface.co/unsloth/Phi-4-mini-instruct-GGUF/resolve/main/Phi-4-mini-instruct-Q4_K_M.gguf"
# =============================
# Weather Configuration
# =============================
WEATHER_DEFAULT_LOCATION = "Utrecht,Netherlands" # Default location for weather queries
# =============================
# Knowledge And Media Tools
# =============================
WIKIPEDIA_TIMEOUT = 5
WEB_SEARCH_TIMEOUT = 10
WEB_SEARCH_DEFAULT_RESULTS = 3
SPOTIFY_CLIENT_ID = os.getenv("SPOTIFY_CLIENT_ID", "")
SPOTIFY_CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRET", "")
SPOTIFY_REDIRECT_URI = os.getenv("SPOTIFY_REDIRECT_URI", "http://127.0.0.1:8888/callback")
SPOTIFY_CACHE_PATH = os.path.join(BASE_DIR, ".spotify_cache")
SPOTIFY_DEVICE_ID = os.getenv("SPOTIFY_DEVICE_ID", "")
SPOTIFY_DEVICE_NAME = os.getenv("SPOTIFY_DEVICE_NAME", "")
# =============================
# Performance Settings
# =============================
SAVE_DEBUG_RECORDINGS = False # Set to True to save audio recordings for debugging (slower)
LLM_MAX_TOKENS = 768 # Allows long spoken answers and detailed stories
LLM_LONG_MAX_TOKENS = 1024 # Extra budget for expansive long-form answers
LLM_TEMPERATURE = 0.6 # Slightly lower for faster, more deterministic generation
LLM_LONG_TEMPERATURE = 0.7 # Slightly higher for more creative long answers
CONVERSATION_MEMORY_TURNS = 8 # Number of user/assistant turns to keep for follow-up context