sS witAI_recognizeAudio(File audioFile, S mimeType) { ret witAI_recognizeAudio(audioFile, mimeType, 'english); } sS witAI_recognizeAudio(File audioFile, S mimeType, S language) ctex { if (audioFile.length() == 0) fail("No file: " + audioFile); print("Calling wit.ai with " + toK(audioFile.length()) + " K " + mimeType + "..."); long time = sysNow(); 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); OutputStream out = con.getOutputStream(); file2stream(audioFile, out); out.flush(); S json = loadPage(con, url); print(json); out.close(); done2_always("wit.ai", time); ret getString(jsonDecodeMap(json), "_text"); }