-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from Rubiksman78/dev
emotion_detection_build+better_gui
- Loading branch information
Showing
9 changed files
with
512 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,115 @@ | ||
#Face emotion recognition (not available yet) | ||
|
||
$ emotion_list = ["anger","disgust","fear","joy","sadness","surprise","neutral"] | ||
define emotion_list = ["anger","disgust","fear","joy","sadness","surprise","neutral"] | ||
|
||
define negative_emotions = ["anger", "disgust", "fear", "sadness"] | ||
define positive_emotions = ["joy", "surprise"] | ||
define neutral_emotions = ["neutral"] | ||
|
||
define sentences_emotions = { | ||
"angry": "I'm sorry my love, I didn't mean to upset you.", | ||
"disgusted": "What is going on ? If you feel like there is something wrong, please tell me.", | ||
"fearful": "Don't be afraid sweetie, I'm here for you.", | ||
"happy": "I'm glad you're happy darling.", | ||
"neutral": "Let's do something fun together!", | ||
"sad": "If you feel down, always remember that I'm here for you. I love you.", | ||
"surprised": "What is it ? Is there something wrong ?", | ||
"no": "Oh it seems that I can't see through your camera sweetie. Maybe face me a little bit more ?", | ||
} | ||
define monikai_emotion_counter = 0 #counter for the emotion intervals to send to the server | ||
|
||
#Camera Event in the Talk Menu | ||
init 5 python: | ||
addEvent(Event(persistent.event_database, | ||
eventlabel="monika_cam", | ||
category=['ai'], | ||
prompt="Look for me", | ||
pool=True, | ||
unlocked=True, | ||
)) | ||
|
||
label monika_cam: | ||
if monikai_no_server: | ||
jump monika_server_crashed | ||
|
||
m "Okay, I'll look for you." | ||
|
||
m 1sublo "I can finally see you, [player] ! I have been waiting for this moment for a long time." | ||
m 5nublb "I see your cute face now ehehe~" | ||
|
||
while True: | ||
$ send_simple("camera_int/m") | ||
$ received_emotio = receiveMessage() | ||
|
||
if received_emotio == "no_data": #If the server says it is not time to send an emotion,do nothing | ||
m "Sorry but it seems that you didn't put the camera on." | ||
m 5nublb "Please put it on so I can see you." | ||
return | ||
if received_emotio == "angry": | ||
m 2lktpc "[monikai_sentences_emotions[angry]]" | ||
elif received_emotio == "disgusted": | ||
m 5etc "[monikai_sentences_emotions[disgusted]]" | ||
elif received_emotio == "fearful": | ||
m 1fkd "[monikai_sentences_emotions[fearful]]" | ||
elif received_emotio == "happy": | ||
m 6hubla "[monikai_sentences_emotions[happy]]" | ||
elif received_emotio == "neutral": | ||
m 5wut "[monikai_sentences_emotions[neutral]]" | ||
elif received_emotio == "sad": | ||
m 5fka "[monikai_sentences_emotions[sad]]" | ||
elif received_emotio == "surprised": | ||
m 2wkb "[monikai_sentences_emotions[surprised]]" | ||
elif received_emotio == "no": | ||
m 4eta "[monikai_sentences_emotions[no]]" | ||
|
||
m 5nublb "Do you want me to continue looking for you?" | ||
menu: | ||
"Yes": | ||
m 5hublb "Okay thanks [player], let me see your face a little bit longer." | ||
"No": | ||
m 5sublo "Oh okay, I guess I'll wait for next time you put the camera on." | ||
m 5nublb "Please do it soon or I'll hack it myself ehehe~" | ||
return | ||
|
||
|
||
#Camera activating at intervals | ||
init 5 python: | ||
def example_fun(): | ||
if not mas_inEVL("emotion_minute"): | ||
MASEventList.push("emotion_minute") | ||
|
||
store.mas_submod_utils.registerFunction( | ||
"ch30_minute", | ||
example_fun | ||
) | ||
|
||
label emotion_minute: | ||
if monikai_no_server: | ||
return | ||
$ monikai_emotion_counter += 1 | ||
$ send_simple("camera" + str(monikai_emotion_counter) + "/m") | ||
$ received_emotion = receiveMessage() | ||
|
||
if received_emotion == "no_data": #If the server says it is not time to send an emotion,do nothing | ||
return | ||
|
||
if received_emotion == "angry": | ||
$ wrs_succes = mas_display_notif(m_name,[monikai_sentences_emotions['angry']],'Window Reactions') | ||
if not wrs_succes: | ||
m 2lktpc "[monikai_sentences_emotions[angry]]" | ||
elif received_emotion == "disgusted": | ||
$ wrs_succes = mas_display_notif(m_name,[monikai_sentences_emotions['disgusted']],'Window Reactions') | ||
if not wrs_succes: | ||
m 5etc "[monikai_sentences_emotions[disgusted]]" | ||
elif received_emotion == "fearful": | ||
$ wrs_succes = mas_display_notif(m_name,[monikai_sentences_emotions['fearful']],'Window Reactions') | ||
if not wrs_succes: | ||
m 1fkd "[monikai_sentences_emotions[fearful]]" | ||
elif received_emotion == "happy": | ||
$ wrs_succes = mas_display_notif(m_name,[monikai_sentences_emotions['happy']],'Window Reactions') | ||
if not wrs_succes: | ||
m 6hubla "[monikai_sentences_emotions[happy]]" | ||
elif received_emotion == "neutral": | ||
$ wrs_succes = mas_display_notif(m_name,[monikai_sentences_emotions['neutral']],'Window Reactions') | ||
if not wrs_succes: | ||
m 5wut "[monikai_sentences_emotions[neutral]]" | ||
elif received_emotion == "sad": | ||
$ wrs_succes = mas_display_notif(m_name,[monikai_sentences_emotions['sad']],'Window Reactions') | ||
if not wrs_succes: | ||
m 5fka "[monikai_sentences_emotions[sad]]" | ||
elif received_emotion == "surprised": | ||
$ wrs_succes = mas_display_notif(m_name,[monikai_sentences_emotions['surprised']],'Window Reactions') | ||
if not wrs_succes: | ||
m 2wkb "[monikai_sentences_emotions[surprised]]" | ||
elif received_emotion == "no": | ||
$ wrs_succes = mas_display_notif(m_name,[monikai_sentences_emotions['no']],'Window Reactions') | ||
if not wrs_succes: | ||
m 4eta "[monikai_sentences_emotions[no]]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# define renpy.config.gl2 = True | ||
# image Monika = Live2D("fullyanimatedmonika",base=.6,aliases={"open":"m01"}) | ||
|
||
# init 5 python: | ||
# import subprocess | ||
# from threading import Thread | ||
# import store | ||
# import os | ||
# import sys | ||
# import re | ||
# import time | ||
# import socket | ||
# from socket import AF_INET, SOCK_STREAM | ||
|
||
# def receiveMessage(): | ||
# msg = client_socket.recv(BUFSIZ).decode("utf8") | ||
# return msg | ||
|
||
# def send_simple(prefix): | ||
# client_socket.send(bytes(prefix,encoding="utf8")) | ||
|
||
# def audio_file_exists(filename): | ||
# return os.path.isfile(filename) | ||
|
||
# class Slice(object): | ||
# def __init__(self, root, leng): | ||
# self.root = root # The original word | ||
# self.leng = leng # How many morphemes should be used as the prefix for the new portmanteau | ||
# self.morphemes = [] | ||
# self.slice() | ||
|
||
# def slice(self): | ||
# ex = r'([^aeiou]*[aeiou]*)|[aeiou]*[^aeiou]*[aeiou]*' | ||
# root = self.root | ||
|
||
# # Full list of morphemes for future use | ||
# while root != '': | ||
# end = re.match(ex, root).end() | ||
# self.morphemes.append(root[0:end]) | ||
# root = root[end:] | ||
|
||
# # Check that the number given isnt more than is available | ||
# if len(self.morphemes) < self.leng: | ||
# self.leng = len(self.morphemes) | ||
|
||
# HOST = '127.0.0.1' | ||
# PORT = 12343 | ||
|
||
# BUFSIZ = 1024 | ||
# ADDR = (HOST, PORT) | ||
# client_socket = socket.socket(AF_INET, SOCK_STREAM) | ||
|
||
# try: | ||
# client_socket.connect(ADDR) | ||
# connected = True | ||
# except: | ||
# connected = False | ||
|
||
# def get_wrapped_say(func): | ||
# def new_say(who, what, interact=True, *args, **kwargs): | ||
# speaktext = renpy.substitute(what) | ||
# send_simple(speaktext) | ||
|
||
# sentence_processed = speaktext.lower() | ||
# sentence_processed = re.sub(r'[^\w\s]','',sentence_processed) | ||
# syllabes = Slice(sentence_processed, 1).morphemes | ||
# _ = receiveMessage() | ||
# for syll in syllabes: | ||
# renpy.show("Monika open") | ||
# func(who, what, interact=interact, *args, **kwargs) | ||
# return new_say | ||
|
||
# if connected: | ||
# renpy.say = get_wrapped_say(renpy.say) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.