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