sclass StreamingWitAIUploader { S mimeType = "audio/mpeg3"; URLConnection con; OutputStream out; S language = "english"; void start { print("Initiating wit.ai call"); S token = witAITokenForLanguage(language); URL url = new URL("https://api.wit.ai/speech?v=20160526"); URLConnection con = url.openConnection(); con.setRequestProperty("Authorization", "Bearer " + token); con.setRequestProperty("Content-Type", mimeType); con.setDoOutput(true); out = con.getOutputStream(); } void sendData(byte[] data) { out.write(data); } void done { out.flush(); S json = loadPage(con, url); dispose out; ret getString(jsonDecodeMap(json), "_text"); } void cleanMeUp { dispose out; } }