main
reng 5 months ago
parent 6d2efc79c0
commit b53b275161
  1. BIN
      vite/public/assets/q4-2.mp3
  2. BIN
      vite/public/assets/q4-2__.mp3
  3. 8
      vite/public/cuelist_free.json
  4. 2
      vite/src/comps/debug.jsx
  5. 41
      vite/src/pages/flow_free.jsx
  6. 14
      vite/src/util/chat.js

Binary file not shown.

Binary file not shown.

@ -34,7 +34,7 @@
"type": "phone",
"description": "引導撥號",
"auto": false,
"audioFile": "assets/0721/onyx/q4.mp3",
"audioFile": "assets/q4.mp3",
"nextcue": 4.1,
"callback":"numpad"
},
@ -44,7 +44,7 @@
"type": "phone",
"description": "電話開頭",
"auto": true,
"audioFile": "assets/0721/onyx/q4-1.mp3",
"audioFile": "assets/q4-1.mp3",
"nextcue": 4.2
},
{
@ -53,7 +53,7 @@
"type": "phone",
"description": "示範影片,引導回憶",
"auto": true,
"audioFile": "assets/0721/onyx/q4-2.mp3",
"audioFile": "assets/q4-2.mp3",
"nextcue": 4.3,
"status":"intro",
"callback":"fade_out_light"
@ -99,7 +99,7 @@
"name": "Q5.3",
"type": "phone",
"description": "ending",
"audioFile": "assets/0721/onyx/q5-2.mp3",
"audioFile": "assets/q5-2.mp3",
"auto": true,
"nextcue": 6
},

@ -1,7 +1,7 @@
import { sendOsc, OSC_ADDRESS, updatePrompt } from "../util/osc"
import { useData } from '../util/useData.jsx';
const TEST_PROMPT='a hazy memory of a {{ light }}, seen through soft atmospheric blur, distant silhouettes and faded contours, pastel light and cinematic haze, (analog film texture), (shallow depth of field:1.3), shallow depth of field, memory fragment effect, light leak, subtle grain, chromatic aberration, surreal glow, in muted warm tones, cinematic framing,';
export const TEST_PROMPT='A distant, ambient setting with gentle light';
export function DebugControl({refLight}){

@ -11,7 +11,7 @@ import { Light } from "../comps/light";
import { useData } from "../util/useData";
import VoiceAnalysis from "../comps/voiceanalysis";
import { sendOsc, OSC_ADDRESS, updatePrompt } from "../util/osc";
import { DebugControl } from "../comps/debug";
import { DebugControl, TEST_PROMPT } from "../comps/debug";
const EmojiType={
@ -27,6 +27,7 @@ const ChatStatus={
System: 'system',
User: 'user',
Processing: 'processing',
Clear: 'clear',
}
const Voice={
@ -104,6 +105,24 @@ export function FreeFlow(){
if(refCurrentCue.current?.type!='chat') onCueEnd();
else{
setChatStatus(ChatStatus.User); // Reset chat status to User after audio ends
// if history contains user input, send it
const user_input = history.find(msg => msg.role === 'user');
if(user_input && user_input.content.trim() !== '') {
sendOsc(OSC_ADDRESS.STATUS, 'go'); // Send OSC status message
}
// send prompt
let raw_prompt=history[history.length-1]?.prompt || '';
if(raw_prompt && raw_prompt.trim() !== '') {
const prompt = `${data?.sd_prompt_prefix || ''}${raw_prompt}${data?.sd_prompt_suffix || ''}`;
updatePrompt(prompt);
sendOsc(OSC_ADDRESS.PROMPT, prompt);
}
}
}
@ -112,7 +131,8 @@ export function FreeFlow(){
if(refCurrentCue.current?.type!='chat' && refCurrentCue.current?.type!='user_input') {
refTimer.current?.restart(audio.duration*1000 || 0);
}else{
setChatStatus(()=>ChatStatus.System);
if(refCurrentCue.current?.type=='chat') setChatStatus(()=>ChatStatus.System);
else setChatStatus(()=>ChatStatus.Clear);
}
});
}
@ -129,7 +149,7 @@ export function FreeFlow(){
console.log('clear conversation...');
reset();
const prompt = `${data?.sd_prompt_prefix || ''}${'memory'}${data?.sd_prompt_suffix || ''}`;
const prompt = `${data?.sd_prompt_prefix || ''}${TEST_PROMPT}${data?.sd_prompt_suffix || ''}`;
updatePrompt(prompt);
}
@ -149,10 +169,12 @@ export function FreeFlow(){
console.log('Ending conversation with message:', message);
sendMessage(message, false, true, voice);
setChatWelcome(false);
setChatStatus(ChatStatus.Clear);
break;
case 'summary':
console.log('Getting summary...');
setChatStatus(ChatStatus.Clear); // Set chat status to Processing
getSummary(history.map(el=>`${el.role}:${el.content}`).join('\n'), data).then(summary => {
console.log('Summary:', summary);
@ -164,6 +186,7 @@ export function FreeFlow(){
}).catch(error => {
console.error('Error getting summary:', error);
});
break;
case 'user_input':
console.log('User input cue, setting chat status to User');
@ -189,7 +212,7 @@ export function FreeFlow(){
// control unity
if(cue.status){
if(cue.status && cue.status!='go') {
sendOsc(OSC_ADDRESS.STATUS, cue.status); // Send OSC status message
if(cue.status=='reset') {
refLight.current.set(1);
@ -302,7 +325,7 @@ export function FreeFlow(){
}
useEffect(()=>{
console.log('Final transcript changed:', finalTranscript);
// console.log('Final transcript changed:', finalTranscript);
if(finalTranscript.trim().length > 0) {
onSpeechEnd();
}
@ -382,7 +405,7 @@ export function FreeFlow(){
useEffect(()=>{
switch(status) {
case Status.SUCCESS:
console.log('Success!');
console.log('Success!');
setStatus(Status.IDLE);
refInput.current.value = '';
@ -425,11 +448,11 @@ export function FreeFlow(){
<NumPad onSend={onNumpad} />
<Light ref={refLight} />
<VoiceAnalysis/>
<div className="flex flex-col">
{/* <div className="flex flex-col">
<label className="text-center">Voice</label>
<button className={`${voice==Voice.ONYX && 'bg-gray-300'}`} onClick={() => setVoice(Voice.ONYX)}>Onyx</button>
<button className={`${voice==Voice.SHIMMER && 'bg-gray-300'}`} onClick={() => setVoice(Voice.SHIMMER)}>Shimmer</button>
</div>
</div> */}
<button className="!bg-yellow-300" onClick={()=>{
saveHistory(history);
}}>Save Log</button>

@ -105,12 +105,14 @@ export async function sendChatMessage(messages, data, isLastMessage = false) {
const rawPrompt = result.prompt?.replaceAll('"', '');
if(rawPrompt && rawPrompt.trim() !== '') {
const prompt = `${data?.sd_prompt_prefix || ''}${rawPrompt}${data?.sd_prompt_suffix || ''}`;
setTimeout(async ()=>{
await updatePrompt(prompt);
await sendOsc(OSC_ADDRESS.PROMPT, prompt);
}, DELAY_SEND_PROMPT);
// const prompt = `${data?.sd_prompt_prefix || ''}${rawPrompt}${data?.sd_prompt_suffix || ''}`;
// setTimeout(async ()=>{
// await updatePrompt(prompt);
// await sendOsc(OSC_ADDRESS.PROMPT, prompt);
// }, DELAY_SEND_PROMPT);
}
// TODO: send to python

Loading…
Cancel
Save