|
|
|
@@ -535,6 +535,7 @@ const ChatScreen: React.FC = () => {
|
|
|
|
|
audioRequestId,
|
|
|
|
|
...(location && { location }),
|
|
|
|
|
});
|
|
|
|
|
scheduleStaleAudioCleanup(audioRequestId, result.durationMs);
|
|
|
|
|
// resume() wird durch onPlaybackFinished nach ARIAs Antwort getriggert.
|
|
|
|
|
} else {
|
|
|
|
|
// Kein Speech im Window → Konversation beenden (Ohr geht aus oder
|
|
|
|
@@ -656,6 +657,29 @@ const ChatScreen: React.FC = () => {
|
|
|
|
|
|
|
|
|
|
// --- Nachricht senden ---
|
|
|
|
|
|
|
|
|
|
// Aufraeumen von "verarbeitet"-Placeholder die nie ein STT-Result bekommen
|
|
|
|
|
// haben (leere Aufnahme, Wake-Word-Echo, STT-Fehler etc). Timeout skaliert
|
|
|
|
|
// mit der Aufnahmedauer — Whisper braucht auf der Gamebox grob real-time/5,
|
|
|
|
|
// plus Bridge-Roundtrip + Network. Formel: 60s Buffer + 1x Aufnahmedauer.
|
|
|
|
|
// Bei 5min Aufnahme = 6 min Wait, bei 5s Aufnahme = 65s. Sicher genug damit
|
|
|
|
|
// langsame STTs nicht versehentlich aufgeraeumt werden.
|
|
|
|
|
const scheduleStaleAudioCleanup = useCallback((audioRequestId: string, recordingMs: number) => {
|
|
|
|
|
const timeoutMs = 60000 + recordingMs;
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
setMessages(prev => {
|
|
|
|
|
const idx = prev.findIndex(m =>
|
|
|
|
|
m.audioRequestId === audioRequestId &&
|
|
|
|
|
m.text.includes('Spracheingabe wird verarbeitet')
|
|
|
|
|
);
|
|
|
|
|
if (idx < 0) return prev;
|
|
|
|
|
console.log('[Chat] Sprachnachricht ohne STT-Result nach %dms entfernt: %s',
|
|
|
|
|
timeoutMs, audioRequestId);
|
|
|
|
|
ToastAndroid.show('Sprachnachricht nicht erkannt — entfernt', ToastAndroid.SHORT);
|
|
|
|
|
return prev.filter((_, i) => i !== idx);
|
|
|
|
|
});
|
|
|
|
|
}, timeoutMs);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const sendTextMessage = useCallback(async () => {
|
|
|
|
|
const text = inputText.trim();
|
|
|
|
|
|
|
|
|
@@ -743,7 +767,8 @@ const ChatScreen: React.FC = () => {
|
|
|
|
|
audioRequestId,
|
|
|
|
|
...(location && { location }),
|
|
|
|
|
});
|
|
|
|
|
}, [getCurrentLocation, interruptAriaIfBusy]);
|
|
|
|
|
scheduleStaleAudioCleanup(audioRequestId, result.durationMs);
|
|
|
|
|
}, [getCurrentLocation, interruptAriaIfBusy, scheduleStaleAudioCleanup]);
|
|
|
|
|
|
|
|
|
|
// Datei auswaehlen → zur Pending-Liste hinzufuegen
|
|
|
|
|
const handleFileSelected = useCallback(async (file: FileData) => {
|
|
|
|
|