Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aefdff89dc | ||
|
|
f99e90f524 | ||
|
|
1dd47888a8 | ||
|
|
8b22557ca5 |
@@ -79,8 +79,8 @@ android {
|
||||
applicationId "com.ariacockpit"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 20007
|
||||
versionName "0.2.0.7"
|
||||
versionCode 20008
|
||||
versionName "0.2.0.8"
|
||||
// Fallback fuer Libraries mit Product Flavors
|
||||
missingDimensionStrategy 'react-native-camera', 'general'
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aria-cockpit",
|
||||
"version": "0.2.0.7",
|
||||
"version": "0.2.0.8",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"android": "react-native run-android",
|
||||
|
||||
@@ -49,7 +49,7 @@ import VoiceButton from '../components/VoiceButton';
|
||||
import FileUpload, { FileData } from '../components/FileUpload';
|
||||
import CameraUpload, { PhotoData } from '../components/CameraUpload';
|
||||
import MessageText from '../components/MessageText';
|
||||
import { loadConvWindowMs, loadTtsSpeed, TTS_SPEED_DEFAULT } from '../services/audio';
|
||||
import { loadConvWindowMs, loadTtsSpeed, TTS_SPEED_DEFAULT, loadSttEndpointMs } from '../services/audio';
|
||||
import Geolocation from '@react-native-community/geolocation';
|
||||
|
||||
// --- Typen ---
|
||||
@@ -562,6 +562,14 @@ const ChatScreen: React.FC = () => {
|
||||
// Wake Word: einmalig laden + Porcupine vorbereiten (wenn Access Key gesetzt)
|
||||
useEffect(() => {
|
||||
wakeWordService.loadFromStorage().catch(() => {});
|
||||
// Mikro-Release-Hook: vor jedem Re-Arm eine laufende (passive) Streaming-
|
||||
// Aufnahme canceln, sonst haelt sie das Mikro und OpenWakeWord.start()
|
||||
// schlaegt fehl → Ohr bleibt ausgegraut (state=off).
|
||||
wakeWordService.setMicReleaseHook(async () => {
|
||||
if (audioService.isStreamingRecording()) {
|
||||
await audioService.cancelStreamingRecording('rearm-mic-free');
|
||||
}
|
||||
});
|
||||
const unsub = wakeWordService.onStateChange((s) => {
|
||||
setWakeWordState(s);
|
||||
setWakeWordActive(s !== 'off');
|
||||
@@ -1465,7 +1473,7 @@ const ChatScreen: React.FC = () => {
|
||||
interrupted: wasInterrupted,
|
||||
location: location || null,
|
||||
noSpeechTimeoutMs: windowMs,
|
||||
endpointMs: 1500,
|
||||
endpointMs: await loadSttEndpointMs(),
|
||||
hardCapMs: 60000,
|
||||
projectId: focusedProjectIdRef.current,
|
||||
});
|
||||
@@ -1561,7 +1569,7 @@ const ChatScreen: React.FC = () => {
|
||||
interrupted: true, // Barge-In → Brain weiss "User hat unterbrochen"
|
||||
location: location || null,
|
||||
noSpeechTimeoutMs: windowMs,
|
||||
endpointMs: 1500,
|
||||
endpointMs: await loadSttEndpointMs(),
|
||||
hardCapMs: 60000,
|
||||
projectId: focusedProjectIdRef.current,
|
||||
});
|
||||
@@ -1618,7 +1626,7 @@ const ChatScreen: React.FC = () => {
|
||||
interrupted: false,
|
||||
location: location || null,
|
||||
noSpeechTimeoutMs: Math.min(passiveMs, 30000),
|
||||
endpointMs: 1500,
|
||||
endpointMs: await loadSttEndpointMs(),
|
||||
hardCapMs: Math.max(passiveMs + 5000, 35000),
|
||||
projectId: focusedProjectIdRef.current,
|
||||
});
|
||||
@@ -2028,7 +2036,7 @@ const ChatScreen: React.FC = () => {
|
||||
// Stoppen). Hard-Cap 5 Minuten als Notbremse — danach killt Whisper
|
||||
// die Session auch app-seitig haben wir +2s Toleranz.
|
||||
noSpeechTimeoutMs: 0,
|
||||
endpointMs: 1500,
|
||||
endpointMs: await loadSttEndpointMs(),
|
||||
hardCapMs: 300000,
|
||||
projectId: focusedProjectIdRef.current,
|
||||
});
|
||||
|
||||
@@ -151,6 +151,26 @@ export const CONV_WINDOW_MIN_SEC = 3.0;
|
||||
export const CONV_WINDOW_MAX_SEC = 20.0;
|
||||
export const CONV_WINDOW_STORAGE_KEY = 'aria_conv_window_sec';
|
||||
|
||||
// STT-Endpoint (ms Stille bis "fertig gesprochen"). Zu kurz = schneidet mitten
|
||||
// im Satz ab, besonders im Auto wo man mit Pausen spricht (Reproduktion: die
|
||||
// 11.8s-Frage wurde bei "…ohne dass ein" gekappt). 1500 war zu aggressiv;
|
||||
// 2400 default, im Auto ggf. hoeher. Konfigurierbar in den Settings.
|
||||
export const STT_ENDPOINT_DEFAULT_MS = 2400;
|
||||
export const STT_ENDPOINT_MIN_MS = 1000;
|
||||
export const STT_ENDPOINT_MAX_MS = 4000;
|
||||
export const STT_ENDPOINT_STORAGE_KEY = 'aria_stt_endpoint_ms';
|
||||
|
||||
export async function loadSttEndpointMs(): Promise<number> {
|
||||
try {
|
||||
const raw = await AsyncStorage.getItem(STT_ENDPOINT_STORAGE_KEY);
|
||||
if (raw != null) {
|
||||
const n = parseInt(raw, 10);
|
||||
if (isFinite(n) && n >= STT_ENDPOINT_MIN_MS && n <= STT_ENDPOINT_MAX_MS) return n;
|
||||
}
|
||||
} catch {}
|
||||
return STT_ENDPOINT_DEFAULT_MS;
|
||||
}
|
||||
|
||||
// TTS-Wiedergabegeschwindigkeit — wird pro Geraet gespeichert und an die
|
||||
// Bridge mitgegeben (speed-Param im F5-TTS infer()). 1.0 = normal.
|
||||
export const TTS_SPEED_DEFAULT = 1.0;
|
||||
|
||||
@@ -132,6 +132,12 @@ class WakeWordService {
|
||||
* hier eine streaming-Aufnahme OHNE User-Bubble (passiv lauschen). */
|
||||
private passiveListenCallbacks: PassiveListenCallback[] = [];
|
||||
|
||||
/** Hook, der das Mikro freigibt (laufende Streaming-Aufnahme canceln) BEVOR
|
||||
* wir OpenWakeWord.start() rufen. Ohne das haelt die passive/conversing
|
||||
* Aufnahme das Mikro noch, start() schlaegt fehl → Ohr bleibt ausgegraut
|
||||
* (state=off). ChatScreen registriert den Hook mit audioService.cancel…. */
|
||||
private micReleaseHook: (() => Promise<void>) | null = null;
|
||||
|
||||
private keyword: WakeKeyword = DEFAULT_KEYWORD;
|
||||
private nativeReady: boolean = false;
|
||||
private initInProgress: Promise<boolean> | null = null;
|
||||
@@ -149,6 +155,19 @@ class WakeWordService {
|
||||
}
|
||||
}
|
||||
|
||||
/** ChatScreen registriert hier einen Hook, der eine laufende Streaming-
|
||||
* Aufnahme cancelt (Mikro freigeben) — wird vor jedem Re-Arm gerufen. */
|
||||
setMicReleaseHook(fn: (() => Promise<void>) | null): void {
|
||||
this.micReleaseHook = fn;
|
||||
}
|
||||
|
||||
private async _freeMic(): Promise<void> {
|
||||
if (!this.micReleaseHook) return;
|
||||
try { await this.micReleaseHook(); } catch (e) {
|
||||
console.warn('[WakeWord] micReleaseHook err:', e);
|
||||
}
|
||||
}
|
||||
|
||||
/** Settings-Wechsel: anderes Wake-Word. Re-Init des Native-Moduls. */
|
||||
async configure(keyword: string): Promise<boolean> {
|
||||
const next: WakeKeyword = (WAKE_KEYWORDS as readonly string[]).includes(keyword)
|
||||
@@ -454,6 +473,7 @@ class WakeWordService {
|
||||
// als state extra zu fragen, garantiert dass nach diesem Pfad
|
||||
// Native auch wirklich an ist falls es out-of-band gestoppt wurde.
|
||||
try {
|
||||
await this._freeMic(); // Streaming-Aufnahme canceln → Mikro frei
|
||||
await OpenWakeWord.start();
|
||||
console.log('[WakeWord] Konversation zu Ende — zurueck zu armed (wasBarge=%s)', wasBarge);
|
||||
import('./logger').then(m => m.reportAppDebug('wake.end',
|
||||
@@ -520,6 +540,7 @@ class WakeWordService {
|
||||
// timeout oder manual → Wake-Word reaktivieren, armed-State.
|
||||
if (this.nativeReady && OpenWakeWord) {
|
||||
try {
|
||||
await this._freeMic(); // passive Streaming-Aufnahme canceln → Mikro frei
|
||||
await OpenWakeWord.start();
|
||||
console.log('[WakeWord] zurueck zu armed nach passive-listen');
|
||||
ToastAndroid.show(`Lausche wieder auf "${KEYWORD_LABELS[this.keyword]}"`, ToastAndroid.SHORT);
|
||||
@@ -564,6 +585,7 @@ class WakeWordService {
|
||||
this.lastTriggerAt = 0;
|
||||
if (this.nativeReady && OpenWakeWord) {
|
||||
try {
|
||||
await this._freeMic(); // ggf. laufende Aufnahme canceln → Mikro frei
|
||||
await OpenWakeWord.start();
|
||||
ToastAndroid.show('Hintergrund-Trigger verworfen — lausche wieder', ToastAndroid.SHORT);
|
||||
this.setState('armed');
|
||||
|
||||
+32
-3
@@ -1018,10 +1018,36 @@ META_TOOLS = [
|
||||
# Diese Logik ist generisch — ARIA deklariert die Patterns selbst beim
|
||||
# skill_create / skill_update, das Brain orchestriert nur.
|
||||
|
||||
def _strip_leading_hint_blocks(text: str) -> str:
|
||||
"""Entfernt fuehrende Hint-Bloecke `[ ... ]`, die die Bridge an
|
||||
Voice-Nachrichten haengt (GPS-Position, Barge-In-Hinweis). Ohne das matcht
|
||||
KEIN Voice-Befehl je den Fast-Path (Regex ist ^...$-verankert) — selbst
|
||||
'nächstes lied' landete unnoetig bei Claude statt beim 0-Token-Fast-Path."""
|
||||
s = (text or "").strip()
|
||||
prev = None
|
||||
while prev != s:
|
||||
prev = s
|
||||
s = re.sub(r"^\s*\[[^\]]*\]\s*", "", s)
|
||||
return s
|
||||
|
||||
|
||||
def _fold_umlauts(s: str) -> str:
|
||||
"""ä→ae, ö→oe, ü→ue, ß→ss (lowercase erwartet). Whisper liefert echte
|
||||
Umlaute ('Nächstes Lied'), viele Skill-fast_patterns sind aber in ae/oe/ue
|
||||
geschrieben — ohne Faltung matcht das nie."""
|
||||
return (s.replace("ä", "ae").replace("ö", "oe").replace("ü", "ue")
|
||||
.replace("ß", "ss"))
|
||||
|
||||
|
||||
def _normalize_for_fast_match(text: str) -> str:
|
||||
norm = (text or "").strip().lower()
|
||||
norm = re.sub(r"[.!?]+$", "", norm)
|
||||
norm = re.sub(r"\s+", " ", norm)
|
||||
norm = _strip_leading_hint_blocks(text).lower()
|
||||
norm = _fold_umlauts(norm)
|
||||
# Interne Satzzeichen raus, die Whisper einstreut ('Nächstes Lied, bitte.').
|
||||
# Kommas/Semikola/Doppelpunkte → Space, Punkt/!/? ganz weg. Sonst matcht das
|
||||
# ^...$-verankerte fast_pattern nie, weil das Komma dazwischenfunkt.
|
||||
norm = re.sub(r"[,;:]", " ", norm)
|
||||
norm = re.sub(r"[.!?]+", "", norm)
|
||||
norm = re.sub(r"\s+", " ", norm).strip()
|
||||
return norm
|
||||
|
||||
|
||||
@@ -1117,6 +1143,9 @@ class Agent:
|
||||
rx = pat.get("match") or ""
|
||||
if not rx:
|
||||
continue
|
||||
# Pattern GLEICH falten wie den Text — egal ob der Skill-Autor
|
||||
# 'naechstes' oder 'nächstes' geschrieben hat.
|
||||
rx = _fold_umlauts(rx)
|
||||
try:
|
||||
if not re.match(rx, norm, re.IGNORECASE):
|
||||
continue
|
||||
|
||||
+12
-1
@@ -87,6 +87,17 @@ _HARD_HINTS = re.compile(
|
||||
_MAX_LEN_FOR_LOCAL = 220 # laengere Nachrichten = eher komplexe Aufgaben → Claude
|
||||
|
||||
|
||||
def _strip_leading_hint_blocks(text: str) -> str:
|
||||
"""Fuehrende `[ ... ]`-Hint-Bloecke (GPS, Barge-In von der Bridge) weg —
|
||||
sonst blaeht der Praefix die Laenge auf und verfaelscht die Heuristik."""
|
||||
s = (text or "").strip()
|
||||
prev = None
|
||||
while prev != s:
|
||||
prev = s
|
||||
s = re.sub(r"^\s*\[[^\]]*\]\s*", "", s)
|
||||
return s
|
||||
|
||||
|
||||
def should_try_local(user_message: str, cfg: dict) -> bool:
|
||||
"""True, wenn der Router diesen Turn (B1a, reden-only) lokal versuchen soll.
|
||||
localOnly überschreibt die Heuristik (dann IMMER lokal)."""
|
||||
@@ -94,7 +105,7 @@ def should_try_local(user_message: str, cfg: dict) -> bool:
|
||||
return False
|
||||
if cfg.get("localOnly"):
|
||||
return True
|
||||
msg = (user_message or "").strip()
|
||||
msg = _strip_leading_hint_blocks(user_message)
|
||||
if not msg or len(msg) > _MAX_LEN_FOR_LOCAL:
|
||||
return False
|
||||
if _TOOL_HINTS.search(msg):
|
||||
|
||||
@@ -3006,6 +3006,24 @@ class ARIABridge:
|
||||
if self._is_duplicate_client_msg(client_msg_id):
|
||||
return
|
||||
|
||||
# Text-Fenster-Dedup: im Auto cancelt der App-No-Speech-Watchdog den
|
||||
# Stream vorzeitig und startet passives Lauschen, waehrend die Bridge
|
||||
# dieselbe Aeusserung parallel noch finalisiert → derselbe Befehl
|
||||
# kaeme zweimal (aus ZWEI verschiedenen audioRequestIds, darum greift
|
||||
# die ID-Idempotenz oben nicht). Identischen Endpoint-Text innerhalb
|
||||
# 5s verwerfen. Genuines "nächstes, nächstes" liegt praktisch immer
|
||||
# weiter auseinander (man hoert den Wechsel erst).
|
||||
_norm_txt = " ".join(text.lower().split())
|
||||
_now_t = asyncio.get_event_loop().time()
|
||||
if (_norm_txt
|
||||
and _norm_txt == getattr(self, "_last_endpoint_norm", "")
|
||||
and (_now_t - getattr(self, "_last_endpoint_at", 0.0)) < 5.0):
|
||||
logger.info("[rvs] stt_endpoint Dupe verworfen (gleicher Text <5s): %r",
|
||||
text[:60])
|
||||
return
|
||||
self._last_endpoint_norm = _norm_txt
|
||||
self._last_endpoint_at = _now_t
|
||||
|
||||
# App-Focus aus stt_stream_start-Registry auflösen (falls die
|
||||
# App-Version die projectId noch nicht mitschickt: leer = Hauptchat).
|
||||
stream_req_id = payload.get("requestId", "") or ""
|
||||
|
||||
Reference in New Issue
Block a user