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"); }
Began life as a copy of #1007049
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, snaazhdonpnp, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1017980 |
Snippet name: | witAI_recognizeAudio |
Eternal ID of this version: | #1017980/6 |
Text MD5: | e4edfc49a70865cd5912f11ee56e9d2f |
Author: | stefan |
Category: | javax / speech recognition |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-07 23:14:51 |
Source code size: | 911 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 429 / 461 |
Version history: | 5 change(s) |
Referenced in: | [show references] |