ULTRACOMBOS-DEV 3 months ago
commit d634b8ea79
  1. 3
      vite/package.json
  2. BIN
      vite/public/assets/ai/sfx-06-ai-04-record-03-ai-05-sfx-07.mp3
  3. 4
      vite/src/comps/debug.jsx
  4. 84
      vite/src/pages/flow_free.jsx
  5. 1
      vite/src/util/osc.js
  6. 11
      vite/src/util/useUser.jsx

@ -7,7 +7,8 @@
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"lint": "eslint .", "lint": "eslint .",
"preview": "vite preview" "preview": "vite preview",
"deploy":"tauri build && copy /Y src-tauri\\target\\release\\app.exe C:\\uc\\24070-Sync\\app.exe"
}, },
"dependencies": { "dependencies": {
"@tailwindcss/vite": "^4.1.8", "@tailwindcss/vite": "^4.1.8",

@ -1,7 +1,7 @@
import { sendOsc, OSC_ADDRESS, updatePrompt } from "../util/osc" import { sendOsc, OSC_ADDRESS, updatePrompt } from "../util/osc"
import { useData } from '../util/useData.jsx'; import { useData } from '../util/useData.jsx';
export const TEST_PROMPT='A distant, ambient setting with gentle light'; export const TEST_PROMPT='a window frame, beach outside, island far away';
export function DebugControl({refLight}){ export function DebugControl({refLight}){
@ -24,7 +24,7 @@ export function DebugControl({refLight}){
<button onClick={() => sendOsc(OSC_ADDRESS.STATUS, 'end')}>end</button> <button onClick={() => sendOsc(OSC_ADDRESS.STATUS, 'end')}>end</button>
{/* <div className="flex flex-col gap-1"> */} {/* <div className="flex flex-col gap-1"> */}
<button className="btn btn-success" onClick={() => sendPrompt('a dog')}>Test Prompt #1</button> <button className="btn btn-success" onClick={() => sendPrompt('a telephone on table with light')}>Test Prompt #1</button>
<button className="btn btn-success" onClick={() => sendPrompt(TEST_PROMPT)}>Test Prompt #2</button> <button className="btn btn-success" onClick={() => sendPrompt(TEST_PROMPT)}>Test Prompt #2</button>
{/* </div> */} {/* </div> */}
</div> </div>

@ -14,6 +14,7 @@ import VoiceAnalysis from "../comps/voiceanalysis";
import { sendOsc, OSC_ADDRESS, updatePrompt, onOscMessageReceived, sendOscStatus } from "../util/osc"; import { sendOsc, OSC_ADDRESS, updatePrompt, onOscMessageReceived, sendOscStatus } 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_demo3.json'; const CUELIST_FILE = 'cuelist_demo3.json';
@ -56,6 +57,9 @@ export function FreeFlow(){
const [audioInput, setAudioInput] = useState(true); const [audioInput, setAudioInput] = useState(true);
const [autoSend, setAutoSend] = useState(true); const [autoSend, setAutoSend] = useState(true);
const [chatStatus, setChatStatus] = useState(ChatStatus.System); // System, User, Processing 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 { userId, setUserId, getFileId, setPassword, reset:resetUser, uploadHistory, setSummary, summary,setChoice,choice, getUploadFolder,getDataId } = useUser();
const refTimer=useRef(); const refTimer=useRef();
@ -93,6 +97,7 @@ export function FreeFlow(){
reset(); reset();
sendOsc(OSC_ADDRESS.CHOICE, 'reset'); sendOsc(OSC_ADDRESS.CHOICE, 'reset');
sendOsc(OSC_ADDRESS.SPEECH, 'stop');
} }
function onOsc(payload){ function onOsc(payload){
@ -233,6 +238,9 @@ export function FreeFlow(){
if(!cue) return; if(!cue) return;
console.log('Playing cue:', cue); console.log('Playing cue:', cue);
// stop audio
if(refAudio.current) refAudio.current.pause();
@ -254,6 +262,7 @@ export function FreeFlow(){
// clear unity hint // clear unity hint
sendOsc(OSC_ADDRESS.HINT, ''); // Clear hint message sendOsc(OSC_ADDRESS.HINT, ''); // Clear hint message
sendOsc(OSC_ADDRESS.INPUT, ''); // Clear input message sendOsc(OSC_ADDRESS.INPUT, ''); // Clear input message
sendOsc(OSC_ADDRESS.SPEECH, 'stop');
switch(cue.type){ switch(cue.type){
case 'chat': case 'chat':
@ -280,17 +289,28 @@ export function FreeFlow(){
setChatStatus(ChatStatus.Clear); // Set chat status to Processing setChatStatus(ChatStatus.Clear); // Set chat status to Processing
let message=refInput.current?.value?.trim() || history.map(el=>`${el.role}:${el.content}`).join('\n'); let message=refInput.current?.value?.trim() || history.map(el=>`${el.role}:${el.content}`).join('\n');
getSummary(message, data).then(summary_ => { console.log('Summary input message:', message);
if(!message || message.length==0) {
console.log('Summary:', summary_); setSummary();
console.log('no message input, clear summary');
onCueEnd(); // End the current cue after getting summary onCueEnd(); // End the current cue after getting summary
setSummary(()=>summary_?.result); }else{
refContainer.current.scrollTop = refContainer.current.scrollHeight; // Scroll to bottom
getSummary(message, data).then(summary_ => {
}).catch(error => {
console.error('Error getting summary:', error); console.log('Summary:', summary_);
}); onCueEnd(); // End the current cue after getting summary
setSummary(()=>summary_?.result);
refContainer.current.scrollTop = refContainer.current.scrollHeight; // Scroll to bottom
}).catch(error => {
console.error('Error getting summary:', error);
});
}
break; break;
@ -363,7 +383,7 @@ export function FreeFlow(){
}else{ }else{
sendOsc(OSC_ADDRESS.HINT, ''); // Clear hint message sendOsc(OSC_ADDRESS.HINT, ''); // Clear hint message
} }
sendOsc(OSC_ADDRESS.SPEECH, 'stop');
refAudio.current?.pause(); // Pause any playing audio refAudio.current?.pause(); // Pause any playing audio
console.log('onCueEnd:', cue.id); console.log('onCueEnd:', cue.id);
@ -395,23 +415,34 @@ export function FreeFlow(){
function onNumpad(mess){ 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; if(refCurrentCue.current?.callback!='numpad') return;
let cue=refCurrentCue.current; let cue=refCurrentCue.current;
let next=cue.nextcue; let next=cue.nextcue;
switch(cue.numpad_type){ switch(cue.numpad_type){
case NUMPAD_TYPE.USERID: case NUMPAD_TYPE.USERID:
setUserId(()=>mess); setUserId(()=>padInput);
break; break;
case NUMPAD_TYPE.CHOICE: case NUMPAD_TYPE.CHOICE:
next=cue.branch[mess.toString()].nextcue; next=cue.branch[padInput.toString()].nextcue;
setChoice(cue.branch[mess.toString()].description); // Set choice for user input setChoice(()=>cue.branch[padInput.toString()].description); // Set choice for user input
break; break;
case NUMPAD_TYPE.PASSWORD: case NUMPAD_TYPE.PASSWORD:
setPassword(()=>mess); setPassword(()=>padInput);
// sendOsc(OSC_ADDRESS.PASSWORD, mess); // Send OSC password message // 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 sendOsc(OSC_ADDRESS.CHOICE, choice); // Send OSC save choice message
break; break;
} }
@ -421,10 +452,9 @@ export function FreeFlow(){
console.log('Finish enter number, next cue:', next); console.log('Finish enter number, next cue:', next);
playCue(cuelist.find(c => c.id === next)); playCue(cuelist.find(c => c.id === next));
} }
}
function saveImage(){
sendOsc('/export', 'output/test.png'); // Send OSC message to save image },[padInput]);
}
useEffect(()=>{ useEffect(()=>{
@ -437,6 +467,8 @@ export function FreeFlow(){
function onSpeechEnd(){ function onSpeechEnd(){
sendOsc(OSC_ADDRESS.SPEECH, 'stop');
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
if(chatStatus!=ChatStatus.User) return; // Only process if chat status is User if(chatStatus!=ChatStatus.User) return; // Only process if chat status is User
@ -555,8 +587,13 @@ export function FreeFlow(){
if(refPauseTimer.current) clearTimeout(refPauseTimer.current); if(refPauseTimer.current) clearTimeout(refPauseTimer.current);
refSpeechPaused.current=false; refSpeechPaused.current=false;
} }
sendOsc(OSC_ADDRESS.SPEECH, 'start');
sendOscStatus(OSC_ADDRESS.CLIENT_INPUT, `${data.id}#${transcript}`); // Send current input via OSC sendOscStatus(OSC_ADDRESS.CLIENT_INPUT, `${data.id}#${transcript}`);
// Send current input via OSC
} }
},[transcript]); },[transcript]);
@ -590,6 +627,7 @@ export function FreeFlow(){
text = ''; text = '';
break; break;
} }
sendOsc(OSC_ADDRESS.SPEECH, 'stop');
sendOsc(OSC_ADDRESS.INPUT, text); sendOsc(OSC_ADDRESS.INPUT, text);
},[chatStatus]); },[chatStatus]);
@ -626,6 +664,8 @@ export function FreeFlow(){
}else{ }else{
playCue(next); playCue(next);
setNextCue(null); setNextCue(null);
} }
@ -693,9 +733,7 @@ export function FreeFlow(){
<span></span> <span></span>
<span>UserId</span><span>{userId}</span> <span>UserId</span><span>{userId}</span>
<span>FileId</span><span>{getFileId()}</span> <span>FileId</span><span>{getFileId()}</span>
<button className="!bg-yellow-300 col-span-2" onClick={()=>{ <span>Choice</span><span>{choice || ''}</span>
saveHistory(history);
}}>Save Log</button>
</div> </div>

@ -17,6 +17,7 @@ export const OSC_ADDRESS={
DISCARD: 'discard', DISCARD: 'discard',
PASSWORD: '/password', PASSWORD: '/password',
HINT:'/hint', HINT:'/hint',
SPEECH:'/speech',
CLIENT_STATUS:'/client', CLIENT_STATUS:'/client',
CLIENT_INPUT:'/client_input', CLIENT_INPUT:'/client_input',

@ -1,4 +1,4 @@
import { createContext, useState, useEffect, useContext, use } from "react"; import { createContext, useState, useEffect, useContext, use, useRef } from "react";
import moment from "moment"; import moment from "moment";
import { updateUser } from "./backend"; import { updateUser } from "./backend";
import { useData } from "./useData"; import { useData } from "./useData";
@ -23,6 +23,8 @@ export function UserProvider({children}) {
const [choice, setChoice] = useState(null); const [choice, setChoice] = useState(null);
const [summary, setSummary] = useState(null); const [summary, setSummary] = useState(null);
const refChoice=useRef();
const {data}=useData(); const {data}=useData();
@ -114,11 +116,16 @@ export function UserProvider({children}) {
console.log("Session ID changed:", sessionId); console.log("Session ID changed:", sessionId);
}, [sessionId]); }, [sessionId]);
// useEffect(()=>{
// refChoice.current=choice;
// console.log("Choice changed:", choice);
// }, [choice]);
return ( return (
<userContext.Provider value={{ <userContext.Provider value={{
userId, setUserId, getFileId, getUploadFolder, userId, setUserId, getFileId, getUploadFolder,
reset, uploadHistory: saveHistory, setChoice, choice, reset, uploadHistory: saveHistory, setChoice,
choice,
setSummary, summary, getDataId, setSummary, summary, getDataId,
setPassword}}> setPassword}}>
{children} {children}

Loading…
Cancel
Save