|
|
|
@ -46,7 +46,7 @@ export function FreeFlow(){ |
|
|
|
const [userId, setUserId] = useState(); |
|
|
|
const [userId, setUserId] = useState(); |
|
|
|
const [summary, setSummary] = useState(null); |
|
|
|
const [summary, setSummary] = useState(null); |
|
|
|
const [voice, setVoice] = useState(Voice.ONYX); |
|
|
|
const [voice, setVoice] = useState(Voice.ONYX); |
|
|
|
|
|
|
|
//const [speechPaused, setSpeechPaused]=useState(false); |
|
|
|
|
|
|
|
|
|
|
|
const [chatStatus, setChatStatus] = useState(ChatStatus.System); // System, User, Processing |
|
|
|
const [chatStatus, setChatStatus] = useState(ChatStatus.System); // System, User, Processing |
|
|
|
|
|
|
|
|
|
|
|
@ -55,6 +55,9 @@ export function FreeFlow(){ |
|
|
|
const refInput=useRef(); |
|
|
|
const refInput=useRef(); |
|
|
|
const refLight=useRef(); |
|
|
|
const refLight=useRef(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const refPauseTimer=useRef(); |
|
|
|
|
|
|
|
const refSpeechPaused=useRef(false); |
|
|
|
|
|
|
|
|
|
|
|
const refContainer=useRef(); |
|
|
|
const refContainer=useRef(); |
|
|
|
|
|
|
|
|
|
|
|
const refCurrentCue= useRef(null); |
|
|
|
const refCurrentCue= useRef(null); |
|
|
|
@ -194,6 +197,9 @@ export function FreeFlow(){ |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
sendOsc(OSC_ADDRESS.COUNTDOWN, '0'); // Reset countdown for non-chat cues |
|
|
|
sendOsc(OSC_ADDRESS.COUNTDOWN, '0'); // Reset countdown for non-chat cues |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(refPauseTimer.current) clearTimeout(refPauseTimer.current); |
|
|
|
|
|
|
|
refSpeechPaused.current=false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function onCueEnd() { |
|
|
|
function onCueEnd() { |
|
|
|
@ -232,6 +238,8 @@ export function FreeFlow(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onNumpad(mess){ |
|
|
|
function onNumpad(mess){ |
|
|
|
|
|
|
|
console.log('Numpad input:', mess); |
|
|
|
|
|
|
|
|
|
|
|
if(refCurrentCue.current?.callback!='numpad') return; |
|
|
|
if(refCurrentCue.current?.callback!='numpad') return; |
|
|
|
|
|
|
|
|
|
|
|
console.log('Numpad input:', mess); |
|
|
|
console.log('Numpad input:', mess); |
|
|
|
@ -252,9 +260,22 @@ export function FreeFlow(){ |
|
|
|
|
|
|
|
|
|
|
|
function onSpeechEnd(){ |
|
|
|
function onSpeechEnd(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(currentCue?.type!='chat') return; // Only process if current cue is user input |
|
|
|
if(currentCue?.type!='chat') return; // Only process if current cue is user input |
|
|
|
console.log('onSpeechEnd:', finalTranscript); |
|
|
|
|
|
|
|
|
|
|
|
console.log('on speech end, start timer'); |
|
|
|
|
|
|
|
refSpeechPaused.current=true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(refPauseTimer.current) clearTimeout(refPauseTimer.current); |
|
|
|
|
|
|
|
refPauseTimer.current=setTimeout(()=>{ |
|
|
|
|
|
|
|
if(refSpeechPaused.current) processSpeech(); |
|
|
|
|
|
|
|
}, data.speech_idle_time); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function processSpeech(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(currentCue?.type!='chat') return; // Only process if current cue is user input |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('processSpeech:', finalTranscript); |
|
|
|
|
|
|
|
|
|
|
|
if(autoSend && transcript.trim().length > 0) { |
|
|
|
if(autoSend && transcript.trim().length > 0) { |
|
|
|
console.log('Auto sending transcript:', transcript); |
|
|
|
console.log('Auto sending transcript:', transcript); |
|
|
|
@ -289,7 +310,7 @@ export function FreeFlow(){ |
|
|
|
const recognition= SpeechRecognition.getRecognition(); |
|
|
|
const recognition= SpeechRecognition.getRecognition(); |
|
|
|
recognition.onspeechstart=(e)=>{ |
|
|
|
recognition.onspeechstart=(e)=>{ |
|
|
|
console.log('Sound start:', e); |
|
|
|
console.log('Sound start:', e); |
|
|
|
|
|
|
|
refSpeechPaused.current=false; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
|