Hi !
I’m trying to get output from my php script in my intent handling local command : handle.py like that:
elif intent == "StartARecord":
process = subprocess.Popen(["curl","-s", "http://1.1.1.1/rec-a-start.php"],stdout=subprocess.PIPE,encoding='utf-8')
data = process.communicate()
for line in data:
if line == "Process via_rec_audio_start.sh is already running\n":
speech('my speech')
But i can’t view any output in data - object. If I try get output in my test python file it work well:
process = subprocess.Popen(["curl","-s", "http://1.1.1.1/rec-a-start.php"],stdout=subprocess.PIPE,encoding='utf-8')
data = process.communicate()
print(data)
I’ma newbie in python. And maybe can me explain where do I dig to get my stdout from php
Are you running the docker version of Rhasspy? I find that If I use the deb version my handle.py script can interface with other parts of the operating system better, like curl, gpio etc…
#!/usr/bin/python3
import sys
import json
import random
import os
from datetime import datetime
#above we import all the crazy things we might need
def speech(text):
global o
o["speech"] = {"text": text}
# get json from stdin and load into python dict
o = json.loads(sys.stdin.read())
intent = o["intent"]["name"]
if intent == "IntroduceSelf":
reply = "I am Marvin. I have been assigned to do voice stuff. Brain the size of a raspberry pi and they turn me into a voice program. All is never ending Woe!"
speech(reply)
# convert dict to json and print to stdout
print(json.dumps(o))