|
@ -21,9 +21,13 @@ void ofTeleprompter::setup() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ofTeleprompter::update() { |
|
|
void ofTeleprompter::update() { |
|
|
// set labels
|
|
|
|
|
|
currentSpeaker = script[currentLine].speaker; |
|
|
if(ofGetFrameNum() < 2) { |
|
|
currentEmotion = script[currentLine].emotion; |
|
|
currentSpeaker = script[currentLine].speaker; |
|
|
|
|
|
currentEmotion = script[currentLine].emotion; |
|
|
|
|
|
currentSentence = script[currentLine].sentence; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
currentLineIndex = ofToString(currentLine + 1) + " / " + ofToString(script.size() + 1); |
|
|
currentLineIndex = ofToString(currentLine + 1) + " / " + ofToString(script.size() + 1); |
|
|
|
|
|
|
|
|
// Teleprompter logic (letter by letter)
|
|
|
// Teleprompter logic (letter by letter)
|
|
@ -44,7 +48,23 @@ void ofTeleprompter::update() { |
|
|
} else { |
|
|
} else { |
|
|
ofJson json = ofJson::parse(llmResponse); |
|
|
ofJson json = ofJson::parse(llmResponse); |
|
|
std::string responseText = json.value("response", ""); |
|
|
std::string responseText = json.value("response", ""); |
|
|
currentSentence = responseText; |
|
|
size_t start = responseText.find('('); |
|
|
|
|
|
size_t end = responseText.find(')'); |
|
|
|
|
|
std::string speaker, sentence; |
|
|
|
|
|
|
|
|
|
|
|
if (start != std::string::npos && end != std::string::npos && end > start) { |
|
|
|
|
|
speaker = responseText.substr(start + 1, end - start - 1); |
|
|
|
|
|
size_t colon = responseText.find(':', end); |
|
|
|
|
|
if (colon != std::string::npos) { |
|
|
|
|
|
sentence = responseText.substr(colon + 1); |
|
|
|
|
|
sentence.erase(0, sentence.find_first_not_of(" \t")); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ofLog() << speaker; |
|
|
|
|
|
currentSentence = sentence; |
|
|
|
|
|
currentSpeaker = speaker; |
|
|
|
|
|
currentEmotion = currentEmotionDetetced; |
|
|
displayedSentence.clear(); |
|
|
displayedSentence.clear(); |
|
|
currentLetterIndex = 0; |
|
|
currentLetterIndex = 0; |
|
|
lastWordTime = ofGetElapsedTimeMillis(); |
|
|
lastWordTime = ofGetElapsedTimeMillis(); |
|
@ -92,9 +112,9 @@ void ofTeleprompter::loadText() { |
|
|
Line l; |
|
|
Line l; |
|
|
int randomIdx = ofRandom(7); |
|
|
int randomIdx = ofRandom(7); |
|
|
l.idx = idx++; |
|
|
l.idx = idx++; |
|
|
l.speaker = entry.value("speaker", ""); |
|
|
l.speaker = entry.value("first_speaker", ""); |
|
|
l.sentence = entry.value("content", ""); |
|
|
l.sentence = entry.value("first_text", ""); |
|
|
l.emotion = emotions[(int)randomIdx]; |
|
|
l.emotion = entry.value("first_emotion", ""); |
|
|
script.push_back(l); |
|
|
script.push_back(l); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
@ -118,8 +138,8 @@ void ofTeleprompter::drawText() { |
|
|
ofSetColor(ofColor::white); |
|
|
ofSetColor(ofColor::white); |
|
|
|
|
|
|
|
|
// --- Display speaker and emotion centered at the top ---
|
|
|
// --- Display speaker and emotion centered at the top ---
|
|
|
std::string speakerText = "Speaker: " + script[currentLine].speaker; |
|
|
std::string speakerText = "Speaker: " + currentSpeaker.getParameter().toString(); |
|
|
std::string emotionText = "Emotion: " + script[currentLine].emotion; |
|
|
std::string emotionText = "Emotion: " + currentEmotion.getParameter().toString(); |
|
|
|
|
|
|
|
|
ofRectangle speakerBox = detailsFont.getStringBoundingBox(speakerText, 0, 0); |
|
|
ofRectangle speakerBox = detailsFont.getStringBoundingBox(speakerText, 0, 0); |
|
|
float speakerX = (ofGetWidth() - speakerBox.width) / 2.0f; |
|
|
float speakerX = (ofGetWidth() - speakerBox.width) / 2.0f; |
|
@ -211,10 +231,12 @@ void ofTeleprompter::nextLinePressed() { |
|
|
std::string emotion = script[currentLine].emotion; |
|
|
std::string emotion = script[currentLine].emotion; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
llmThread.requestPrompt(speaker, sentence, emotion, temperature); |
|
|
llmThread.requestPrompt(speaker, sentence, currentEmotionDetetced, temperature); |
|
|
waitingForLLM = true; |
|
|
waitingForLLM = true; |
|
|
// Don't set currentSentence yet!
|
|
|
// Don't set currentSentence yet!
|
|
|
} else { |
|
|
} else { |
|
|
|
|
|
currentSpeaker = script[currentLine].speaker; |
|
|
|
|
|
currentEmotion = script[currentLine].emotion; |
|
|
currentSentence = script[currentLine].sentence; |
|
|
currentSentence = script[currentLine].sentence; |
|
|
displayedSentence.clear(); |
|
|
displayedSentence.clear(); |
|
|
currentLetterIndex = 0; |
|
|
currentLetterIndex = 0; |
|
@ -228,7 +250,10 @@ void ofTeleprompter::resetScript() { |
|
|
currentLine = 0; |
|
|
currentLine = 0; |
|
|
|
|
|
|
|
|
// Prepare teleprompter effect for letter-by-letter
|
|
|
// Prepare teleprompter effect for letter-by-letter
|
|
|
|
|
|
currentSpeaker = script[currentLine].speaker; |
|
|
|
|
|
currentEmotion = script[currentLine].emotion; |
|
|
currentSentence = script[currentLine].sentence; |
|
|
currentSentence = script[currentLine].sentence; |
|
|
|
|
|
|
|
|
displayedSentence.clear(); |
|
|
displayedSentence.clear(); |
|
|
currentLetterIndex = 0; |
|
|
currentLetterIndex = 0; |
|
|
lastWordTime = ofGetElapsedTimeMillis(); |
|
|
lastWordTime = ofGetElapsedTimeMillis(); |
|
|