Build an open future with us.

Invest in Mycroft and become a community partner.

TranslateSkill unicode, not str


#1

Translate skill gets error.

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

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


#2

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


#3

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.


#4

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

any idea?


#5

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


#6

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


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


#7

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