|
|
|
|
@ -14,6 +14,7 @@ import VoiceAnalysis from "../comps/voiceanalysis"; |
|
|
|
|
import { sendOsc, OSC_ADDRESS, updatePrompt, onOscMessageReceived, sendOscStatus } from "../util/osc"; |
|
|
|
|
import { DebugControl, TEST_PROMPT } from "../comps/debug"; |
|
|
|
|
import { useUser } from "../util/useUser"; |
|
|
|
|
import { set } from 'zod/v4'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CUELIST_FILE = 'cuelist_demo3.json'; |
|
|
|
|
@ -56,6 +57,9 @@ export function FreeFlow(){ |
|
|
|
|
const [audioInput, setAudioInput] = useState(true); |
|
|
|
|
const [autoSend, setAutoSend] = useState(true); |
|
|
|
|
const [chatStatus, setChatStatus] = useState(ChatStatus.System); // System, User, Processing |
|
|
|
|
|
|
|
|
|
const [padInput, setPadInput] = useState(null); |
|
|
|
|
|
|
|
|
|
const { userId, setUserId, getFileId, setPassword, reset:resetUser, uploadHistory, setSummary, summary,setChoice,choice, getUploadFolder,getDataId } = useUser(); |
|
|
|
|
|
|
|
|
|
const refTimer=useRef(); |
|
|
|
|
@ -258,6 +262,7 @@ export function FreeFlow(){ |
|
|
|
|
// clear unity hint |
|
|
|
|
sendOsc(OSC_ADDRESS.HINT, ''); // Clear hint message |
|
|
|
|
sendOsc(OSC_ADDRESS.INPUT, ''); // Clear input message |
|
|
|
|
sendOsc(OSC_ADDRESS.SPEECH, 'stop'); |
|
|
|
|
|
|
|
|
|
switch(cue.type){ |
|
|
|
|
case 'chat': |
|
|
|
|
@ -284,6 +289,16 @@ export function FreeFlow(){ |
|
|
|
|
setChatStatus(ChatStatus.Clear); // Set chat status to Processing |
|
|
|
|
|
|
|
|
|
let message=refInput.current?.value?.trim() || history.map(el=>`${el.role}:${el.content}`).join('\n'); |
|
|
|
|
console.log('Summary input message:', message); |
|
|
|
|
|
|
|
|
|
if(!message || message.length==0) { |
|
|
|
|
|
|
|
|
|
setSummary(); |
|
|
|
|
console.log('no message input, clear summary'); |
|
|
|
|
onCueEnd(); // End the current cue after getting summary |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
getSummary(message, data).then(summary_ => { |
|
|
|
|
|
|
|
|
|
console.log('Summary:', summary_); |
|
|
|
|
@ -295,6 +310,7 @@ export function FreeFlow(){ |
|
|
|
|
}).catch(error => { |
|
|
|
|
console.error('Error getting summary:', error); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
@ -367,7 +383,7 @@ export function FreeFlow(){ |
|
|
|
|
}else{ |
|
|
|
|
sendOsc(OSC_ADDRESS.HINT, ''); // Clear hint message |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sendOsc(OSC_ADDRESS.SPEECH, 'stop'); |
|
|
|
|
|
|
|
|
|
refAudio.current?.pause(); // Pause any playing audio |
|
|
|
|
console.log('onCueEnd:', cue.id); |
|
|
|
|
@ -399,23 +415,34 @@ export function FreeFlow(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onNumpad(mess){ |
|
|
|
|
console.log('Numpad input:', mess); |
|
|
|
|
setPadInput(mess); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(padInput==null) return; |
|
|
|
|
|
|
|
|
|
console.log('Numpad input:', padInput); |
|
|
|
|
if(refCurrentCue.current?.callback!='numpad') return; |
|
|
|
|
|
|
|
|
|
let cue=refCurrentCue.current; |
|
|
|
|
let next=cue.nextcue; |
|
|
|
|
switch(cue.numpad_type){ |
|
|
|
|
case NUMPAD_TYPE.USERID: |
|
|
|
|
setUserId(()=>mess); |
|
|
|
|
setUserId(()=>padInput); |
|
|
|
|
break; |
|
|
|
|
case NUMPAD_TYPE.CHOICE: |
|
|
|
|
next=cue.branch[mess.toString()].nextcue; |
|
|
|
|
setChoice(cue.branch[mess.toString()].description); // Set choice for user input |
|
|
|
|
next=cue.branch[padInput.toString()].nextcue; |
|
|
|
|
setChoice(()=>cue.branch[padInput.toString()].description); // Set choice for user input |
|
|
|
|
break; |
|
|
|
|
case NUMPAD_TYPE.PASSWORD: |
|
|
|
|
setPassword(()=>mess); |
|
|
|
|
setPassword(()=>padInput); |
|
|
|
|
// sendOsc(OSC_ADDRESS.PASSWORD, mess); // Send OSC password message |
|
|
|
|
sendOsc(OSC_ADDRESS.EXPORT, `${getUploadFolder()}#${getDataId()}#${summary}#${getFileId(mess)}`); |
|
|
|
|
const user_input = history.find(msg => msg.role === 'user'); |
|
|
|
|
const default_image=!(user_input && user_input.content.trim() !== ''); |
|
|
|
|
|
|
|
|
|
sendOsc(OSC_ADDRESS.EXPORT, `${getUploadFolder()}#${getDataId()}#${summary||''}#${getFileId(padInput)}#${choice||''}#${default_image?'default':'generated'}`); // Send OSC export message |
|
|
|
|
sendOsc(OSC_ADDRESS.CHOICE, choice); // Send OSC save choice message |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
@ -425,10 +452,9 @@ export function FreeFlow(){ |
|
|
|
|
console.log('Finish enter number, next cue:', next); |
|
|
|
|
playCue(cuelist.find(c => c.id === next)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
function saveImage(){ |
|
|
|
|
sendOsc('/export', 'output/test.png'); // Send OSC message to save image |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},[padInput]); |
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
|
|
|
|
|
|
@ -562,10 +588,13 @@ export function FreeFlow(){ |
|
|
|
|
refSpeechPaused.current=false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sendOsc(OSC_ADDRESS.SPEECH, 'start'); |
|
|
|
|
|
|
|
|
|
sendOscStatus(OSC_ADDRESS.CLIENT_INPUT, `${data.id}#${transcript}`); |
|
|
|
|
// Send current input via OSC |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
sendOsc(OSC_ADDRESS.SPEECH, 'start'); |
|
|
|
|
|
|
|
|
|
},[transcript]); |
|
|
|
|
|
|
|
|
|
@ -703,9 +732,7 @@ export function FreeFlow(){ |
|
|
|
|
<span></span> |
|
|
|
|
<span>UserId</span><span>{userId}</span> |
|
|
|
|
<span>FileId</span><span>{getFileId()}</span> |
|
|
|
|
<button className="!bg-yellow-300 col-span-2" onClick={()=>{ |
|
|
|
|
saveHistory(history); |
|
|
|
|
}}>Save Log</button> |
|
|
|
|
<span>Choice</span><span>{choice || ''}</span> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|