fixes comm blocking bot and feedback
This commit is contained in:
parent
d603ee8820
commit
26044ff53b
1 changed files with 16 additions and 4 deletions
|
|
@ -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;
|
||||
if (speechRecognitionRef.current === recognition) {
|
||||
speechRecognitionRef.current = null;
|
||||
setIsUserSpeaking(false);
|
||||
transcriptPartsRef.current = [];
|
||||
setLiveTranscript('');
|
||||
if (speechRecognitionRef.current === recognition) {
|
||||
try {
|
||||
recognition.start();
|
||||
} catch {
|
||||
speechRecognitionRef.current = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue