Uses 16925K of libraries. Click here for Pure Java version (5055L/34K/119K).
!7 static JButton button; static volatile Capturer cap; static File wavFile; static Q recognizerQueue; p-substance { showControls(jCenteredLine(button = jbutton("Record!", f recordOrStop))); recognizerQueue = new Q("Recognizer Queue", true); thread { kevin(""); } // init speech synthesizer } svoid recordOrStop { if (cap != null) { cap.stop(); byte[] pcm = cap.getPCM(); infoMessage("Got " + l(pcm) + " bytes PCM!"); pcmToWAVE(pcm, cap.format(), wavFile); //infoBox("Wrote " + f2s(wavFile) + " (" + wavFile.length() + " bytes)"); cap = null; setText(button, "Record!"); recognizeAudio(wavFile); } else { AudioLine line = first(allTargetDataLines()); assertNotNull("Need audio input line!", line); DataLine dataLine = cast line.open(); print("Capturing"); wavFile = prepareProgramFile(ymd_minus_hms() + ".wav"); cap = captureAudioFromLine2(dataLine, sphinxAudioFormat()); setText(button, "Stop"); } } svoid recognizeAudio(final File wavFile) { recognizerQueue.add(r { loading { print("Recognizing audio..."); /*File mp3File = new File(wavFile.getPath() + ".mp3"); wavToMP3(wavFile, mp3File);*/ S line = witAI_recognizeWAV(wavFile); print("Done recognizing"); infoBox("You said: " + line); kevin(line); // repeat what user said } }); }
Began life as a copy of #1007039
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1007047 |
Snippet name: | Your voice -> wit.ai -> Kevin [WORKS with wit.ai token] |
Eternal ID of this version: | #1007047/11 |
Text MD5: | fdac5974d46aeea7695035a277b35b2a |
Transpilation MD5: | deae880e42d36588f4112a3b15e11519 |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-26 15:25:32 |
Source code size: | 1418 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 518 / 631 |
Version history: | 10 change(s) |
Referenced in: | [show references] |