Mycroft Community Forum

Recipe skill for Mycroft_gui

hi there . though it not quite finished as i integrated my original recipe skill into a gui versions. and I have not fully migrated it yet. but I was just wonder what people might think of it, if they try it…

it works reasonably well and easy you need lynx installed ( sudo apt install lynx) as that my preferred method as I find it easier then beautiful soup and much faster faster to process webpages and modification of webpage decoding is easier later on ( webpages format changes)

once installed just say
get/find “at least two search item-maximum of 8 items” recipe
ie: get spicy wing chicken recipe
find eggs peppers onions flour recipe
it will list 20 search items

just say item number
ie 14

it should display image ( depending on internet speed) you can always go back and view image afterwards just scroll right after the recipe is displayed

then starts display on recipe

I still have to install a sub process yet as mycroft still does not know how to handle fractions ( but it should read correctly if using google speech engine- even though google speech engine no longer works for me to test it out) and add in a few more functions

( is it just me or did alot stuff get broken in mycroft lately as my last version 18 still works fine , but 23 or what this new one is half of everything not working)


Interestingly, Lingua Franca currently supports fractions on their own, or before another number - “1/3” turns into 0.333333333 , and “1/3 4” turns into [0.333333, 4.0] - but as soon as there’s a number ahead of the fraction, the fraction causes a bug:

“3 1/3” --> [3.0, 3.0]

The parser responsible is due for a rewrite, but the FOSSies and Mycroft employee who work on that module are overwhelmed. I do apologize for the inconvenience in the meantime, we know it’s bizarre.


if you wish to try the newest almost finished version it has some more functions. same link as above or click here

to download list of recipes off the web

[ITEM or ITEMS] recipe
ie -> “lemon cake recipes”
to stop it from requesting item number say “new search”
to save recipe from web to your favorites say “save recipe”

to view list of locally saved recipes say “my recipes”
to choose recipe say “recipe [RECIPE NAME]”
to email recipe say “email recipe” ( configure email script with your setting)

to save screenshot create folder recipes in your Picture folder

example image from screenshoot


okay I created a github for it found here

I also added a fraction translator to it so it mycroft translate fraction better. it does not do all fraction just the most common fraction for recipes.

– also curiously is any one having issues of mycroft rolling back edits to skills . sometimes after a day or over night some of my edits are lost to the skills as it rolled back… which is kind of annoying especially if you figure out a bug then a couple days later it back and you have to reedit again.

Altough it’s the “allrecipe_com” skill, do you see the possibilty to feed multiple (eg international) sources with the online bash script? (or is the skill too allrecipey alltogether? just went through the online script)

it not particularly hard to add in other sites. is there a site you were interested in… i just choose the recipe site that has the most usage and recipes as it ranked #1 for english language. basically all I need it change the bash script slightly add in language descriptor and have that point to that website then strip the recipe from it and pull the image links

easiest way look at process_recipe it explains every thing in there.

simplest comment everything between

sed -n ‘/^Ingredients/,/^Nutrition Facts/p;/^Nutrition Facts/q’ |
sed ‘s/. /\n/g’

then do a lynx -dump {web address of a recipe on your website}

replace “Ingredients” with whatever word it using
and find the last word at the end of the recipe dump and replace that in my case it was 'Nutrition Facts"

then just figure out what extra data you need to strip after that

online - which is the dump of the recipe sites search and then strip the recipe and picture URL from it…

Process_recipe3 which is process the recipe webpage and strips the recipe content and image links

FRAC modify that to correct fraction in your language

I could point all my bash scripts to say within the vocab/ en-us/bash/ folder and then different languages can have their own for what ever website is the preferred recipe site

here try this one you should be able to create for multiple languages recipe sites
I created a folder called bash just copy the en-us with in it and paste it with your new language name . and then modify the files mentioned above to scrape the recipe site of your choosing
in the bash folder there one called pics just put your recipe sites logo in there

let me know if you have problems and i will help you out a bit

There are too many things hardcoded that this would work for other languages. For instance:
Line 120 ff
should be replaced by something like

self.is_repeat = False
response = self.get_response('which.recipe.number') #/dialog/lang/which.recipe.number.dialog
num, _ = extract_number(response, self.lang)

if num and num <= 20:
      NUMBER = num
      self.is_recipe = True
elif self.voc_match(response, 'repeat'): #/vocab/lang/repeat.voc
      self.is_repeat = True
      self.is_recipe = False
elif self.voc_match(response,'new_search'): #/vocab/lang/new_search.voc
      self.is_recipe = False
      self.speak_dialog('') #/dialog/lang/

Is there a reason why you wouldn’t use dirname(__ file __) instead of /opt/mycroft/skills/all-recipes-skill/ resp. $HOME/mycroft-core/skills/all-recipes-skill/ (in certain cases) ? Both break things if core doesn’t sit in above HOME or the skill dir isn’t above opt

easy answer to that is I am not very familiar with python - but no worries I will modify with your suggestion easily enough


I’ve seen in Mycroft chat lately that in cases where things are written to the skill directory it’s better practice to use from mycroft.filesystem import FileSystem
(which should access ~/.mycroft/skills/AllRecipes/)

bc “If I use the skill directory this will force a reload of the skill”.

Don’t know much about it. Maybe @JarbasAl can clue you in.

I tried adapting but it breaks here from your suggestion

   num, _ = extract_number(response, self.lang)
 NameError: name 'extract_number' is not defined

from mycroft.util.parse import fuzzy_match, extract_number, match_one, normalize

went slightly further

num, _ = extract_number(response, self.lang)                                                                                                                                    
TypeError: cannot unpack non-iterable int object

get_response() should get you a str, not int

and chage it into

num = extract_number(response, self.lang)

Just saw that it only extracts the number, not like other extracts where t returns additionally the remains, hence , _

oh well mycroft see it as an integer and breaks . i tried a type response a one still the same … but i would think my previous usage of if response ==‘1’ because if I say one in English i should get the same response if I say eins german or un in french… etc as almost everyone use the arabic numeral system

see where you getting at, but in cases someone will answer with “the first” or else you’re shit out of luck. This would give the user a little wiggle room.

but your above does not seam to work from me, I get the error mentioned above and the int error – and currently if they give the wrong response as "the first’ it will continue to ask until it get the correct response any ways so it sort of neither here nor there as it will asks two times then it waits 10 seconds then ask again to give the respondent time to process. and if not it will continue to ask every 10 seconds for 10 cycles.

try this one then I edited i believe everything to to use dialog/vocal and change paths to work differently. the only one i could not change was the logo path

it the same link as above

if you want give me web address of international recipe site you want scraped I will scrape it for you if you like and the language category

by the way the tmp files are not written within the skill folder it written outside the folder so it does not cause the skill to rebuild the only function that does that is the save function but that because it modifies the so you actually need to reload it anyways for it to work…

the recipe bash script says otherwise
(maybe i should add that /mycroft-core/skills links to /opt/mycroft/skills)

yes and that part of the “save recipe function” that edits so the skill has to reload to recognize the newly added recipe to the offline folder