Read the statement by Michael Teeuw here.
MM and Custom Python Script
-
Hello,
I just discovered Magi Mirror and I absolutely LOVE IT! It’s easy to use and it looks awesome!
So I have a custom python scripts that I would love to run alongside my Magic Mirror.
My Python script is a virtual voice assistant that can do google searches, conversions, and more. Anyways, I would love to have that running in the back round while MM is running, instead of using 2 separate Rpi’s. Is that possible? If so, how?
One more thing, my python script has print statements that print to the terminal but I was wondering if they can be rerouted to the compliments scripts that way the results would display on MM then fade out( and the compliments would then show).
Is that possible as well and if so, how can it be done?Thanks in advance?
-
@extra see my PythonPrint module which launches a python script (once and long running) or
end and needs to be rerun (get status of something now)https://github.com/sdetweil/MMM-PythonPrint
so, the python script would hear and translate voice to text and send and module would collect and send to browser side…
one could then do some action or sendNotification(???, text)
so do so action on another module
-
@extra my code can be used to display, and fade out would be a css setting
-
@sdetweil So your PythonPrint module will let me run my python script as MM is running, correct?
And how would I get the print statements to appear like the compliments (same font size, transitions. And if I have 2 sentences that need to be displayed it breaks up the words and fades them in/out in order)?
So basically, I press a button(which unmutes my mic), say my command, and have the results displayed to MM.
Here’s a sample of my python script:
#------------------------------------------------------------------------------------- #Search Wikipedia (General Info) #------------------------------------------------------------------------------------- if ('weather' not in command): if ('who is' in command) or ('what is the' in command) or ('what is a' in command) or ("what is" in command): if ('time' not in command): if ('news' not in command): speak('Searching Wikipedia...') command = command.replace("who is","") command = command.replace("what is the","") command = command.replace("what is a","") command = command.replace("what is","") results = wikipedia.summary(command, sentences = 2) #---------------------- #Auto typing animation: print("Baxter: ", end="") for i in results: sys.stdout.write(i) sys.stdout.flush() time.sleep(0.05) print("\n") #---------------------- speak(results) #------------------------------------------------------------------------------------- #Search Wolfram Alpha (Math/Conversions, Definitions) #------------------------------------------------------------------------------------- if ('weather' not in command): if ('news' not in command): if ('calculate' in command) or ("what's" in command) or ('define' in command): speak('Searching Wolfram Alpha...') command = command.replace("calculate","") command = command.replace("what's","") command = command.replace("define","") # Wolframalpha App Id appId = '' # Wolfram Instance client = wolframalpha.Client(appId) res = client.query(''.join(command)) results = next(res.results).text #---------------------- #Auto typing animation: print("Baxter: ", end="") for i in results: sys.stdout.write(i) sys.stdout.flush() time.sleep(0.05) print("\n") #---------------------- speak(results)
-
@extra my code puts the stdout output of the python script onto the page
you just need to specify css classes in custom.css
try the sample… it launches a python script that runs forever and prints output, the node_helper gets it and sends to module
module displays…
wrapper.innerHTML = this.config.message; wrapper.className += "PythonPrint"
so just set the class values in custom.css
.MMM-PythonPrint .PythonPrint { font-size:24px; color: yellow; }
-
@sdetweil Thanks will do. I just got a little confused, thanks for the clarification.
-
@extra u can use my code as the base for what u need, but it does 95%
splitting lines
easy in JavaScript, split()
how to handle the different lines… that’s your design and implementation
my code assumes one blob of text.