Add Micro auto
This commit is contained in:
@@ -110,6 +110,7 @@ export default function App() {
|
||||
const isRecordingRef = useRef(false)
|
||||
const isAutoListeningRef = useRef(false)
|
||||
const isTranscribingRef = useRef(false)
|
||||
const speakingRef = useRef(false)
|
||||
const levelFrameCountRef = useRef(0)
|
||||
|
||||
const availableVoices = useMemo(() => {
|
||||
@@ -143,6 +144,10 @@ export default function App() {
|
||||
isTranscribingRef.current = isTranscribing
|
||||
}, [isTranscribing])
|
||||
|
||||
useEffect(() => {
|
||||
speakingRef.current = speaking
|
||||
}, [speaking])
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedStudentId) {
|
||||
loadProgress(selectedStudentId)
|
||||
@@ -278,8 +283,20 @@ export default function App() {
|
||||
utterance.voice = selectedVoice
|
||||
}
|
||||
utterance.onstart = () => setSpeaking(true)
|
||||
utterance.onend = () => setSpeaking(false)
|
||||
utterance.onerror = () => setSpeaking(false)
|
||||
utterance.onend = async () => {
|
||||
setSpeaking(false)
|
||||
if (isAutoListeningRef.current && !isRecordingRef.current && !isTranscribingRef.current) {
|
||||
pushAudioDebug('Fin de voix prof, réarmement du segment micro')
|
||||
await startSegmentRecording()
|
||||
}
|
||||
}
|
||||
utterance.onerror = async () => {
|
||||
setSpeaking(false)
|
||||
if (isAutoListeningRef.current && !isRecordingRef.current && !isTranscribingRef.current) {
|
||||
pushAudioDebug('Erreur voix prof, réarmement du segment micro')
|
||||
await startSegmentRecording()
|
||||
}
|
||||
}
|
||||
window.speechSynthesis.speak(utterance)
|
||||
}
|
||||
|
||||
@@ -417,6 +434,10 @@ export default function App() {
|
||||
}
|
||||
|
||||
hasSpeechInSegmentRef.current = false
|
||||
if (isAutoListeningRef.current && !isTranscribingRef.current && !speakingRef.current) {
|
||||
pushAudioDebug('Segment terminé, relance écoute micro')
|
||||
await startSegmentRecording()
|
||||
}
|
||||
}
|
||||
|
||||
recorder.onerror = () => {
|
||||
|
||||
Reference in New Issue
Block a user