Hello everyone,
I’m trying to read or write to a text file(in the same skill directory) and for some reason. My code is not doing that. I have created a simple script to execute the reading file function and it does not work… Please find below my test script.
#******************* Mycroft #
from adapt.intent import IntentBuilder
from mycroft.skills.core import MycroftSkill, intent_handler
from mycroft.util.log import LOG, getLogger
from mycroft.filesystem import FileSystemAccess
#****************************#
#******************* Mycroft ************************#
class ReadtextSkill(MycroftSkill):
# The constructor of the skill, which calls MycroftSkill's constructor
def __init__(self):
super(ReadtextSkill, self).__init__(name="ReadtextSkill")
@intent_handler(IntentBuilder("ReadtextIntent").require("Run").require("Readtext"))
def handle_readtext_intent(self, message):
self.speak_dialog("running")
#****************************************************#
try:
data = “”
filename = “example.txt”
with self.file_system.open(filename, “r”) as my_file:
data = my_file.read()
self.speak_dialog('result', {'TEXT': data})
#****************************************************#
except:
self.speak_dialog("error")
def shutdown(self):
super(ReadtextSkill, self).shutdown()
def stop(self):
pass
def create_skill():
return ReadtextSkill()
#****************************************#
I have checked all the links available in the forum and I have not been able to fix it…
Any ideas ?
Thanks in advance