From 27e81ca002887fb2634f6f494177874f00ccf059 Mon Sep 17 00:00:00 2001 From: reng Date: Tue, 19 Aug 2025 20:24:40 +0800 Subject: [PATCH] update --- vite/src/pages/flow_free.jsx | 65 ++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/vite/src/pages/flow_free.jsx b/vite/src/pages/flow_free.jsx index 60492eb..e26b565 100644 --- a/vite/src/pages/flow_free.jsx +++ b/vite/src/pages/flow_free.jsx @@ -13,7 +13,6 @@ import VoiceAnalysis from "../comps/voiceanalysis"; import { sendOsc, OSC_ADDRESS, updatePrompt, onOscMessageReceived } from "../util/osc"; import { DebugControl, TEST_PROMPT } from "../comps/debug"; import { useUser } from "../util/useUser"; -import { set } from "zod/v4"; const CUELIST_FILE = 'cuelist_demo2.json'; @@ -158,7 +157,7 @@ export function FreeFlow(){ onCueEnd(); console.log('Audio ended, ending current cue'); }else{ - setChatStatus(ChatStatus.User); // Reset chat status to User after audio ends + // if history contains user input, send it @@ -181,12 +180,15 @@ export function FreeFlow(){ console.error("Audio prompt playback error:", error); }); + refAudioPrompt.current.onended = () => { + console.log('Audio prompt ended, setting chat status to User'); + setChatStatus(ChatStatus.User); // Set chat status to User after audio ends + } + + }else{ + setChatStatus(()=>ChatStatus.User); // Reset chat status to User after audio ends } - // if(refChatCueEnd.current){ - // console.log('Talking ended, ending current cue'); - // onCueEnd(); // End the current cue if chat cue has ended - // } } } @@ -229,13 +231,13 @@ export function FreeFlow(){ setChatWelcome(true); resetData(); // Reset data for new conversation break; - case 'chat_end': - const message= refInput.current?.value?.trim(); - console.log('Ending conversation with message:', message); - sendMessage(message, false, true, null); - setChatWelcome(false); - setChatStatus(ChatStatus.Clear); - break; + // case 'chat_end': + // const message= refInput.current?.value?.trim(); + // console.log('Ending conversation with message:', message); + // sendMessage(message, false, true, null); + // setChatWelcome(false); + // setChatStatus(ChatStatus.Clear); + // break; case 'summary': console.log('Getting summary...'); @@ -306,11 +308,11 @@ export function FreeFlow(){ const cue= refCurrentCue.current; // Get the current cue from ref if(cue.type=='chat'){ - // if(chatStatus==ChatStatus.System) { - // console.log('Still talking...'); - // refChatCueEnd.current=true; - // return; - // } + if(chatStatus==ChatStatus.System) { + console.log('Still talking...'); + refChatCueEnd.current=true; + return; + } console.log('save chat history:', history); uploadHistory(history); // Save chat history when cue ends } @@ -432,7 +434,12 @@ export function FreeFlow(){ if(currentCue?.type!='chat') return; // Only process if current cue is user input console.log('processSpeech:', finalTranscript); - + + if(refChatCueEnd.current) { + console.log('Chat cue has ended, do not processing speech'); + onCueEnd(); + return; + } if(autoSend && transcript.trim().length > 0) { console.log('Auto sending transcript:', transcript); // onCueEnd(); @@ -442,12 +449,28 @@ export function FreeFlow(){ console.log('Ending conversation with message:', message); sendMessage(message, false, false, null); setChatWelcome(false); - + setChatStatus(ChatStatus.Processing); // Set chat status to Processing } resetTranscript(); } } + function manualSendMessage() { + if(currentCue?.type!='chat') return; // Only process if current cue is user input + if(chatStatus!=ChatStatus.User) return; // Only process if chat status is User + + const message= refInput.current?.value?.trim(); + if(message && message.length>0) { + console.log('Manual sending message:', message); + sendMessage(message, false, false, null); + setChatWelcome(false); + setChatStatus(ChatStatus.Processing); // Set chat status to Processing + + } + resetTranscript(); + + } + useEffect(()=>{ // console.log('Final transcript changed:', finalTranscript); @@ -692,7 +715,7 @@ export function FreeFlow(){ setAutoSend(e.target.checked)} /> - +
api_status= {status}
chat_status= {chatStatus}