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

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

@ -88,6 +88,8 @@ export function FreeFlow(){
const refFadeOutInterval=useRef();
const refVolDownInterval=useRef();
const refChatTimer=useRef();
const [lastOsc, setLastOsc]=useState();
const { history, status, reset, sendMessage, setStatus, audioOutput, setAudioOutput, stop:stopChat,
@ -486,7 +488,7 @@ export function FreeFlow(){
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
}else{
sendOsc(OSC_ADDRESS.COUNTDOWN, '0'); // Reset countdown for non-chat cues
@ -581,6 +583,27 @@ export function FreeFlow(){
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(()=>{
if(!lastOsc) return;
@ -669,8 +692,15 @@ export function FreeFlow(){
}
function processSpeech(){
if(currentCue?.type!='chat') return; // Only process if current cue is user input
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
console.log('processSpeech:', finalTranscript);
if(refChatCueEnd.current) {
@ -806,6 +836,7 @@ export function FreeFlow(){
break;
case ChatStatus.User:
text = '換你說了';
startChatTimer();
break;
case ChatStatus.Processing:
text = '記憶讀取中';

Loading…
Cancel
Save