Download Jar. Libraryless. Click here for Pure Java version (4544L/33K).
!7 /* curl -XPOST 'https://api.wit.ai/speech?v=20160526' -i -L -H "Authorization: Bearer $TOKEN" -H "Content-Type: audio/wav" --data-binary "@20170226-024709.wav" */ p-tt { // make speech to recognize S originalText = "Dies ist ein Beispieltext"; File mp3File = gudrun_silent(originalText); print("Calling wit.ai with " + toK(mp3File.length()) + " K mp3..."); S token = trim(loadTextFileMandatory(javaxSecretDir("wit-ai-token-german.txt"))); URL url = new URL("https://api.wit.ai/speech?v=20170307&context=" + urlencode(jsonEncode(litmap(locale := "de_DE")))); print(url); URLConnection con = url.openConnection(); con.setRequestProperty("Authorization", "Bearer " + token); con.setRequestProperty("Content-Type", "audio/mpeg3"); con.setDoOutput(true); OutputStream out = con.getOutputStream(); file2stream(mp3File, out); out.flush(); S contents = loadPage(con, url); out.close(); print("JSON:"); print(contents); S text = getString(jsonDecodeMap(contents), "_text"); print("ORIGINAL TEXT: " + originalText); print("RECOGNIZED TEXT: " + text); print(); print(match(originalText, text) ? "FULL MATCH!" : "Not a full match."); }
Began life as a copy of #1007044
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018150 |
Snippet name: | Test wit.ai speech recognition with German .mp3 [OK] |
Eternal ID of this version: | #1018150/11 |
Text MD5: | 216ec6026bfedee74fa5842485481edd |
Transpilation MD5: | e99c42ee2738cea73b8771070bf04253 |
Author: | stefan |
Category: | javax / speech recognition |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-09-04 21:35:04 |
Source code size: | 1231 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 405 / 969 |
Version history: | 10 change(s) |
Referenced in: | [show references] |