|
|
|
|
@ -491,7 +491,8 @@ export function FreeFlow(){ |
|
|
|
|
if(cue.type=='user_input') { |
|
|
|
|
sendOsc(OSC_ADDRESS.COUNTDOWN, cue.duration || '0'); // Send OSC countdown message |
|
|
|
|
}else{ |
|
|
|
|
sendOsc(OSC_ADDRESS.COUNTDOWN, '0'); // Reset countdown for non-chat cues |
|
|
|
|
if(cue.type!='chat') |
|
|
|
|
sendOsc(OSC_ADDRESS.COUNTDOWN, '0'); // Reset countdown for non-chat cues |
|
|
|
|
} |
|
|
|
|
if(cue.numpad_type=='choice'){ |
|
|
|
|
setChoice(); |
|
|
|
|
@ -588,19 +589,27 @@ export function FreeFlow(){ |
|
|
|
|
if(refChatTimer.current) clearInterval(refChatTimer.current); |
|
|
|
|
|
|
|
|
|
let timeleft=refCurrentCue.current?.chatInterval || 0; |
|
|
|
|
const start_time=Date.now(); |
|
|
|
|
refChatTimer.current=setInterval(()=>{ |
|
|
|
|
|
|
|
|
|
let delta_time=(Date.now()-start_time)/1000.0; |
|
|
|
|
timeleft-=delta_time; |
|
|
|
|
const endTime=new Date().getTime()+timeleft*1000; |
|
|
|
|
|
|
|
|
|
function tick(){ |
|
|
|
|
const now=new Date().getTime(); |
|
|
|
|
const timeLeft=endTime-now; |
|
|
|
|
|
|
|
|
|
if(timeleft<=0){ |
|
|
|
|
console.log('~~~ chat timer ended, process speech'); |
|
|
|
|
clearInterval(refChatTimer.current); |
|
|
|
|
// send message |
|
|
|
|
if(chatStatus==ChatStatus.User) processSpeech(); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
}, 1000); |
|
|
|
|
timeleft=Math.max(0, Math.floor(timeLeft/1000)); |
|
|
|
|
|
|
|
|
|
refChatTimer.current=setTimeout(tick, 100); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refChatTimer.current=setTimeout(tick, 100); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -683,10 +692,14 @@ export function FreeFlow(){ |
|
|
|
|
// refSpeechPaused.current=true; |
|
|
|
|
|
|
|
|
|
if(refPauseTimer.current) clearTimeout(refPauseTimer.current); |
|
|
|
|
|
|
|
|
|
sendOsc(OSC_ADDRESS.SPEECH_PAUSE, data.speech_idle_time.toString()); |
|
|
|
|
refPauseTimer.current=setTimeout(()=>{ |
|
|
|
|
console.log('~~~ pause timer ended, process speech'); |
|
|
|
|
// if(refSpeechPaused.current) |
|
|
|
|
processSpeech(); |
|
|
|
|
sendOsc(OSC_ADDRESS.SPEECH_PAUSE, '0'); |
|
|
|
|
|
|
|
|
|
}, data.speech_idle_time); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -708,16 +721,20 @@ export function FreeFlow(){ |
|
|
|
|
onCueEnd(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if(autoSend && transcript.trim().length > 0) { |
|
|
|
|
console.log('Auto sending transcript:', transcript); |
|
|
|
|
// onCueEnd(); |
|
|
|
|
if(autoSend) { |
|
|
|
|
|
|
|
|
|
const message= refInput.current?.value?.trim(); |
|
|
|
|
|
|
|
|
|
if(message && message.length>0) { |
|
|
|
|
console.log('Ending conversation with message:', message); |
|
|
|
|
sendMessage(message, false, false, null); |
|
|
|
|
setChatWelcome(false); |
|
|
|
|
|
|
|
|
|
setChatStatus(ChatStatus.Processing); // Set chat status to Processing |
|
|
|
|
}else{ |
|
|
|
|
console.log('No message input'); |
|
|
|
|
sendMessage('...', false, false, null); |
|
|
|
|
setChatWelcome(false); |
|
|
|
|
setChatStatus(ChatStatus.Processing); // Set chat status to Processing |
|
|
|
|
} |
|
|
|
|
resetTranscript(); |
|
|
|
|
@ -827,6 +844,7 @@ export function FreeFlow(){ |
|
|
|
|
},[audioUrl]); |
|
|
|
|
useEffect(()=>{ |
|
|
|
|
|
|
|
|
|
if(refCurrentCue.current?.type!='chat' && refCurrentCue.current?.type!='user_input') return; |
|
|
|
|
resetTranscript(); |
|
|
|
|
|
|
|
|
|
let text=''; |
|
|
|
|
|