TranslateSkill unicode, not str


Translate skill gets error.

    # sentence = unicode(sentence, "utf-8")
    sentence = unicodedata.normalize('NFKD',sentence).encode('ascii','ignore')

File “/opt/mycroft/skills/TranslateSkill/”, line 73, in say
sentence = unicodedata.normalize(‘NFKD’,sentence).encode(‘ascii’,‘ignore’)
TypeError: must be unicode, not str


The follow change is tested and working
Before …
# sentence = unicode(sentence, “utf-8”)
sentence = unicodedata.normalize(‘NFKD’,sentence).encode(‘ascii’,‘ignore’)
s = unicode(sentence, “utf-8”)
sentence = unicodedata.normalize(‘NFKD’,s).encode(‘ascii’,‘ignore’)


Further testing of this skill is required.

My testing reveal the follow issues…

Hey mycroft, translate good day to french <-- Works
Hey mycroft, translate what time is it to french <-- Only speaks one word est-ce
Hey mycroft translate voulez vous couche avec moi to english <-- This works

Single words kinda work but sentences not so well.


hey @legtod2
I did your suggested following changes, but I have always the same error

any idea?


Hi there @Mohamed_Benaissa - what does your mycroft-skills.log file show?


hey @KathyReid : for example if i try
say in french good morning

i still having the same error
thanks for your help:smile:


Thanks @Mohamed_Benaissa for providing the log information, it is very helpful.

It shows that there is an error in the Skill, in the function handle_translate. The line that does word = message.metadata.get("TranslateKeyword")
assumes that the message.metadata object is not null, but in this case it appears to be null. I would recommend using the LOGGER function to log the contents of the message.metadata object to the mycroft-skills.log file so that we can see why the object is not populated.

This is why the Skill is not responding - the code for the Intent is failing.

Kind regards, Kathy