!7 sS keyphrase = "computer"; // 1e-40 works pretty well with few false positives // 1e-30 gets no hits sS threshold = "1e-35" /*"1e-40"*/ /*"1e-50"*/; sO onKeyPhrase; sS python = trim([[ #!/usr/bin/python from subprocess import Popen, PIPE, STDOUT import pty import os import sys cmd = 'pocketsphinx_continuous -inmic yes -keyphrase #KEYPHRASE# -kws_threshold #THRESHOLD#' master, slave = pty.openpty() p = Popen(cmd, shell=True, stdin=PIPE, stdout=slave, stderr=slave, close_fds=True) stdout = os.fdopen(master) while True: sys.stdout.write(stdout.readline()) sys.stdout.flush() ]]); p { unix_killAll("pocketsphinx"); onKeyPhrase = voidfunc(S s) { infoBox("Yep!"); sendOpt("Kevin", "Yep"); }; File fPython = getProgramFile("pocketsphinx.py"); makeExecutable(saveTextFile(fPython, python.replace("#THRESHOLD#", threshold).replace("#KEYPHRASE#", bashQuote(keyphrase))); backtickToConsole_lineBuf(f2s(fPython), voidfunc(S line) { print("Line read: " + quote(line)); if (eq(line, keyphrase)) pcallF(onKeyPhrase, line); }); }