sclass StreamingWitAIUploader { S mimeType = "audio/mpeg3"; S language = "english"; URL url; URLConnection con; OutputStream out; long bytesSent; void start ctex { print("Initiating wit.ai call"); S token = witAITokenForLanguage(language); url = new URL("https://api.wit.ai/speech?v=20160526"); con = url.openConnection(); con.setRequestProperty("Authorization", "Bearer " + token); con.setRequestProperty("Content-Type", mimeType); con.setDoOutput(true); out = con.getOutputStream(); } void sendData(byte[] data) ctex { out.write(data); bytesSent += l(data); } S get() ctex { if (out == null) null; printWithMilliseconds("Sent " + nBytes(bytesSent) + " to wit.ai"); out.flush(); S json = loadPage(con, url); S text = getString(jsonDecodeMap(json), "_text"); printWithMilliseconds("wit.ai responded: " + text); if (eq(text, "hallo")) { text = ""; print("WIT.AI WORKAROUND"); } dispose out; ret text; } void cleanMeUp { dispose out; } }