reng 2 months ago
parent 3796fe0e49
commit 8bbb834235
  1. 3
      vite/public/cuelist_1009.json
  2. 33
      vite/src/pages/flow_free.jsx

@ -81,7 +81,8 @@
"auto": true, "auto": true,
"nextcue": 4.3, "nextcue": 4.3,
"duration": 90, "duration": 90,
"status":"go" "status":"go",
"chatInterval":20
}, },
{ {
"id": 4.3, "id": 4.3,

@ -88,6 +88,8 @@ export function FreeFlow(){
const refFadeOutInterval=useRef(); const refFadeOutInterval=useRef();
const refVolDownInterval=useRef(); const refVolDownInterval=useRef();
const refChatTimer=useRef();
const [lastOsc, setLastOsc]=useState(); const [lastOsc, setLastOsc]=useState();
const { history, status, reset, sendMessage, setStatus, audioOutput, setAudioOutput, stop:stopChat, const { history, status, reset, sendMessage, setStatus, audioOutput, setAudioOutput, stop:stopChat,
@ -486,7 +488,7 @@ export function FreeFlow(){
resetData(); resetData();
} }
} }
if(cue.type=='chat' || cue.type=='user_input') { if(cue.type=='user_input') {
sendOsc(OSC_ADDRESS.COUNTDOWN, cue.duration || '0'); // Send OSC countdown message sendOsc(OSC_ADDRESS.COUNTDOWN, cue.duration || '0'); // Send OSC countdown message
}else{ }else{
sendOsc(OSC_ADDRESS.COUNTDOWN, '0'); // Reset countdown for non-chat cues sendOsc(OSC_ADDRESS.COUNTDOWN, '0'); // Reset countdown for non-chat cues
@ -581,6 +583,27 @@ export function FreeFlow(){
writeSheet(); writeSheet();
} }
function startChatTimer(){
sendOsc(OSC_ADDRESS.COUNTDOWN, refCurrentCue.current?.chatInterval || '0'); // Send OSC countdown message
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;
if(timeleft<=0){
console.log('~~~ chat timer ended, process speech');
clearInterval(refChatTimer.current);
// send message
if(chatStatus==ChatStatus.User) processSpeech();
}
}, 1000);
}
useEffect(()=>{ useEffect(()=>{
if(!lastOsc) return; if(!lastOsc) return;
@ -669,8 +692,15 @@ export function FreeFlow(){
} }
function processSpeech(){ function processSpeech(){
if(refPauseTimer.current) clearTimeout(refPauseTimer.current);
if(refChatTimer.current) clearInterval(refChatTimer.current);
sendOsc(OSC_ADDRESS.COUNTDOWN, '0'); // Reset countdown
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('processSpeech:', finalTranscript); console.log('processSpeech:', finalTranscript);
if(refChatCueEnd.current) { if(refChatCueEnd.current) {
@ -806,6 +836,7 @@ export function FreeFlow(){
break; break;
case ChatStatus.User: case ChatStatus.User:
text = '換你說了'; text = '換你說了';
startChatTimer();
break; break;
case ChatStatus.Processing: case ChatStatus.Processing:
text = '記憶讀取中'; text = '記憶讀取中';

Loading…
Cancel
Save