On Fri, Nov 29, 2013 at 8:17 PM, richard kappler <richkapp...@gmail.com> wrote: > > args = shlex.split(cmd) > output,error = subprocess.Popen(args,stdout = subprocess.PIPE, stderr= > subprocess.PIPE).communicate()
Output to stderr doesn't necessarily mean a command failed. The process returncode is what you need to inspect. Use subprocess.check_output. It raises a subprocess.CalledProcessError for a non-zero return code. > if not error: > a = eval(output) Please post plain text to the list. Automatic conversion from rich to plain text isn't Python friendly. Don't use eval like this. Google isn't sending Python code in response to a web query. They're sending JSON data: import json output = ('{"status":0,"id":"","hypotheses":' '[{"utterance":"Python","confidence":0.58060002}]}') a = json.loads(output) >>> a['hypotheses'][0] {u'confidence': 0.58060002, u'utterance': u'Python'} >>> a['hypotheses'][0]['utterance'] u'Python' Remember to check the status code. I found a short list, but nothing official: 0 - correct 4 - missing audio file 5 - incorrect audio file When the speech recognition fails to form a hypothesis, print "Ozzy, is that you again?" ;) _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor