Skip to content
Snippets Groups Projects
Commit 8021c91f authored by Oscar Linnarsson's avatar Oscar Linnarsson
Browse files

Merge branch 'fix/text-2-emotion-2' into 'master'

fix: text_2_emotion_2

See merge request !6
parents 938df285 5a2c737a
No related branches found
No related tags found
1 merge request!6fix: text_2_emotion_2
Pipeline #56596 passed
......@@ -11,11 +11,11 @@ RUN if [ "$NO_GPU" = 0 ]; then \
RUN pip3 install transformers
RUN pip3 install dialogflow
RUN pip3 install pygame
# ADD THESE LATER :)
RUN pip3 install text2emotion
# RUN pip3 install tensorflow
# RUN pip3 install pickle
# RUN pip3 install scipy
# For text_2_emotion nodes
RUN pip3 install text2emotion
RUN pip3 install tensorflow
RUN pip3 install scipy
# Install dependencies
COPY src/lhw_interfaces src/lhw_interfaces
......
......@@ -21,6 +21,7 @@ import time
import pickle
import numpy as np
import os
class NodeText2Emotion(Node):
def __init__(self, model, tokenizer):
......@@ -68,36 +69,23 @@ class NodeText2Emotion(Node):
def text_cb(self, text_msg):
""" text_cb.data has the text data """
self.get_logger().info('text callback!')
if text_msg.recognized_text != " ":
self.log.info("Response: " + text_msg.recognized_text)
#--------------CHECK THE CODE BELOW WITH EXPORT SIMON T-----------------------------
print(str(text_msg.recognized_text))
# print(str(text_msg.recognized_text))
emotion_arr = self.analyse_text(str(text_msg.recognized_text))
msg_emotion = self.generateEventT2E(
source_id=Response.TEXT_2_EMOTION_2,
speaker_id='',
emotion_dict=emotion_arr
emotion_arr=emotion_arr[0] # SAMI HAVE A LOOK AT THIS /OSCAR :)
)
self.broadcast_emotion.publish(msg_emotion)
#print('Predicted emotion is: {} and prediction took ({:.2f} seconds)'.format(emotion, pred_time))
# resp_msg = 'Predicted emotion is: {} and prediction took ({:.2f} seconds)'.format(emotion, pred_time)
# msg.recognized_text = resp_msg
# animated_msg.data = "I sense {} in you".format(emotion)
# self.response_pub.publish(msg)
# self.animated_pub.publish(animated_msg)
# msg.response = "TODO: THIS SHOULD BE THE PREDICTED EMOTION"
# self.get_logger().info('publishing: "%s"' % msg.response)
def main(args=None):
model = keras.models.load_model("nlp")
with open('tokenizer.pickle', 'rb') as handle:
path_to_here = os.getcwd() + '/src/lhw_nlp/lhw_nlp/'
model = keras.models.load_model(path_to_here + 'nlp')
with open(path_to_here + 'tokenizer.pickle', 'rb') as handle:
tokenizer = pickle.load(handle)
rclpy.init(args=args)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment