fixes comm blocking bot and feedback

This commit is contained in:
ValueOn AG 2026-03-04 00:09:10 +01:00
parent d603ee8820
commit 26044ff53b

View file

@ -136,14 +136,14 @@ export const CommcoachCoachingView: React.FC = () => {
};
recognition.onspeechstart = () => {
if (cancelled) return;
if (cancelled || coach.isTtsPlayingRef.current) return;
setIsUserSpeaking(true);
transcriptPartsRef.current = [];
setLiveTranscript('');
};
recognition.onresult = (event: SpeechRecognitionEvent) => {
if (cancelled) return;
if (cancelled || coach.isTtsPlayingRef.current) return;
const finalized: string[] = [];
let currentInterim = '';
for (let i = 0; i < event.results.length; i++) {
@ -163,6 +163,12 @@ export const CommcoachCoachingView: React.FC = () => {
recognition.onspeechend = () => {
if (cancelled) return;
if (coach.isTtsPlayingRef.current) {
transcriptPartsRef.current = [];
setLiveTranscript('');
setIsUserSpeaking(false);
return;
}
const fullTranscript = transcriptPartsRef.current.join(' ').trim();
if (fullTranscript) {
const wordCount = fullTranscript.split(/\s+/).filter(Boolean).length;
@ -175,9 +181,15 @@ export const CommcoachCoachingView: React.FC = () => {
recognition.onend = () => {
if (cancelled) return;
setIsUserSpeaking(false);
transcriptPartsRef.current = [];
setLiveTranscript('');
if (speechRecognitionRef.current === recognition) {
speechRecognitionRef.current = null;
setIsUserSpeaking(false);
try {
recognition.start();
} catch {
speechRecognitionRef.current = null;
}
}
};