v2.2 - Small improvement Interface change

This commit is contained in:
pporcheret
2026-10-29 11:13:02 +01:00
parent a17c3cb614
commit 7f26f9b015
271 changed files with 6207 additions and 16044 deletions
+45
View File
@@ -87,6 +87,27 @@ DEFAULTS.update({
from services.admin_extensions_v2 import extend_health as _admin_v2_extend_health
# ALFRED_DUPLEX_BARGE_IN_V1: values saved with existing /config API.
FIELDS.update({
'DUPLEX_MODE': ('general', 'duplex_mode'),
'DUPLEX_MIC_THRESHOLD': ('general', 'duplex_threshold'),
})
DEFAULTS.update({'DUPLEX_MODE': 'wake', 'DUPLEX_MIC_THRESHOLD': '0.025'})
# ALFRED_DUPLEX_CONVERSATION_V2: configurable from the existing authenticated /config page.
FIELDS.update({
'DUPLEX_STOP_COMMANDS': ('general', 'boolean'),
'DUPLEX_HANDOFF': ('general', 'boolean'),
'DUPLEX_CONVERSATION': ('general', 'boolean'),
'DUPLEX_CONVERSATION_SECONDS': ('general', 'duplex_seconds'),
})
DEFAULTS.update({
'DUPLEX_STOP_COMMANDS': 'true',
'DUPLEX_HANDOFF': 'true',
'DUPLEX_CONVERSATION': 'true',
'DUPLEX_CONVERSATION_SECONDS': '6',
})
def _auth_config():
try:
return json.loads(AUTH_FILE.read_text(encoding='utf-8'))
@@ -137,6 +158,30 @@ def _validate(key, value):
if key not in FIELDS:
raise ValueError(f'Paramètre non autorisé : {key}.')
kind = FIELDS[key][1]
# ALFRED_DUPLEX_BARGE_IN_V1
# ALFRED_DUPLEX_CONVERSATION_V2
if kind == 'duplex_seconds':
try:
seconds = int(value)
except (ValueError, TypeError, OverflowError):
raise ValueError('Duree de conversation invalide.')
if isinstance(value, bool) or not 2 <= seconds <= 15:
raise ValueError('Duree de conversation : de 2 a 15 secondes.')
return str(seconds)
if kind == 'duplex_mode':
if value not in ('off', 'wake', 'natural'):
raise ValueError('Mode duplex invalide.')
return value
if kind == 'duplex_threshold':
if isinstance(value, bool):
raise ValueError('Seuil microphone invalide.')
try:
threshold = float(value)
except (ValueError, TypeError, OverflowError):
raise ValueError('Seuil microphone invalide.')
if not 0.008 <= threshold <= 0.30 or not __import__('math').isfinite(threshold):
raise ValueError('Seuil microphone compris entre 0.008 et 0.30.')
return f'{threshold:.3f}'
if kind == 'boolean':
if value not in (True, False, 'true', 'false'):
raise ValueError(f'{key} doit être vrai ou faux.')