|
|
|
@ -13,7 +13,6 @@ import VoiceAnalysis from "../comps/voiceanalysis"; |
|
|
|
import { sendOsc, OSC_ADDRESS, updatePrompt, onOscMessageReceived } from "../util/osc"; |
|
|
|
import { sendOsc, OSC_ADDRESS, updatePrompt, onOscMessageReceived } from "../util/osc"; |
|
|
|
import { DebugControl, TEST_PROMPT } from "../comps/debug"; |
|
|
|
import { DebugControl, TEST_PROMPT } from "../comps/debug"; |
|
|
|
import { useUser } from "../util/useUser"; |
|
|
|
import { useUser } from "../util/useUser"; |
|
|
|
import { set } from "zod/v4"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CUELIST_FILE = 'cuelist_demo2.json'; |
|
|
|
const CUELIST_FILE = 'cuelist_demo2.json'; |
|
|
|
@ -158,7 +157,7 @@ export function FreeFlow(){ |
|
|
|
onCueEnd(); |
|
|
|
onCueEnd(); |
|
|
|
console.log('Audio ended, ending current cue'); |
|
|
|
console.log('Audio ended, ending current cue'); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
setChatStatus(ChatStatus.User); // Reset chat status to User after audio ends |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if history contains user input, send it |
|
|
|
// if history contains user input, send it |
|
|
|
@ -181,12 +180,15 @@ export function FreeFlow(){ |
|
|
|
console.error("Audio prompt playback error:", error); |
|
|
|
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); |
|
|
|
setChatWelcome(true); |
|
|
|
resetData(); // Reset data for new conversation |
|
|
|
resetData(); // Reset data for new conversation |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'chat_end': |
|
|
|
// case 'chat_end': |
|
|
|
const message= refInput.current?.value?.trim(); |
|
|
|
// const message= refInput.current?.value?.trim(); |
|
|
|
console.log('Ending conversation with message:', message); |
|
|
|
// console.log('Ending conversation with message:', message); |
|
|
|
sendMessage(message, false, true, null); |
|
|
|
// sendMessage(message, false, true, null); |
|
|
|
setChatWelcome(false); |
|
|
|
// setChatWelcome(false); |
|
|
|
setChatStatus(ChatStatus.Clear); |
|
|
|
// setChatStatus(ChatStatus.Clear); |
|
|
|
break; |
|
|
|
// break; |
|
|
|
case 'summary': |
|
|
|
case 'summary': |
|
|
|
console.log('Getting summary...'); |
|
|
|
console.log('Getting summary...'); |
|
|
|
|
|
|
|
|
|
|
|
@ -306,11 +308,11 @@ export function FreeFlow(){ |
|
|
|
const cue= refCurrentCue.current; // Get the current cue from ref |
|
|
|
const cue= refCurrentCue.current; // Get the current cue from ref |
|
|
|
|
|
|
|
|
|
|
|
if(cue.type=='chat'){ |
|
|
|
if(cue.type=='chat'){ |
|
|
|
// if(chatStatus==ChatStatus.System) { |
|
|
|
if(chatStatus==ChatStatus.System) { |
|
|
|
// console.log('Still talking...'); |
|
|
|
console.log('Still talking...'); |
|
|
|
// refChatCueEnd.current=true; |
|
|
|
refChatCueEnd.current=true; |
|
|
|
// return; |
|
|
|
return; |
|
|
|
// } |
|
|
|
} |
|
|
|
console.log('save chat history:', history); |
|
|
|
console.log('save chat history:', history); |
|
|
|
uploadHistory(history); // Save chat history when cue ends |
|
|
|
uploadHistory(history); // Save chat history when cue ends |
|
|
|
} |
|
|
|
} |
|
|
|
@ -433,6 +435,11 @@ export function FreeFlow(){ |
|
|
|
|
|
|
|
|
|
|
|
console.log('processSpeech:', finalTranscript); |
|
|
|
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) { |
|
|
|
if(autoSend && transcript.trim().length > 0) { |
|
|
|
console.log('Auto sending transcript:', transcript); |
|
|
|
console.log('Auto sending transcript:', transcript); |
|
|
|
// onCueEnd(); |
|
|
|
// onCueEnd(); |
|
|
|
@ -448,6 +455,22 @@ export function FreeFlow(){ |
|
|
|
resetTranscript(); |
|
|
|
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(()=>{ |
|
|
|
useEffect(()=>{ |
|
|
|
|
|
|
|
|
|
|
|
// console.log('Final transcript changed:', finalTranscript); |
|
|
|
// console.log('Final transcript changed:', finalTranscript); |
|
|
|
@ -692,7 +715,7 @@ export function FreeFlow(){ |
|
|
|
<input type='checkbox' checked={autoSend} onChange={(e) => setAutoSend(e.target.checked)} /> |
|
|
|
<input type='checkbox' checked={autoSend} onChange={(e) => setAutoSend(e.target.checked)} /> |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
<button onClick={resetTranscript}>reset transcript</button> |
|
|
|
<button onClick={resetTranscript}>reset transcript</button> |
|
|
|
<button onClick={sendMessage} disabled={chatStatus!=ChatStatus.User && chatStatus!=ChatStatus.Message}>Send</button> |
|
|
|
<button onClick={manualSendMessage} disabled={chatStatus!=ChatStatus.User && chatStatus!=ChatStatus.Message}>Send</button> |
|
|
|
|
|
|
|
|
|
|
|
<div className="rounded-2xl bg-gray-300 self-end px-4 tracking-widest">api_status= {status}</div> |
|
|
|
<div className="rounded-2xl bg-gray-300 self-end px-4 tracking-widest">api_status= {status}</div> |
|
|
|
<div className="rounded-2xl bg-gray-300 self-end px-4 tracking-widest">chat_status= {chatStatus}</div> |
|
|
|
<div className="rounded-2xl bg-gray-300 self-end px-4 tracking-widest">chat_status= {chatStatus}</div> |
|
|
|
|