Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1019363 // Speech Recognition Confirmation [Did computer understand correctly?, Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 408K of libraries. Click here for Pure Java version (15275L/108K).

1  
!7
2  
3  
module SpeechRecogConfirmation > DynPrintLogAndButtons {
4  
  start {
5  
    onSpeechRecognized_withoutMyUtterancesAndTyped(voidfunc(fS s) {
6  
      print("\nI heard: " + quote(s));
7  
      if (eq(s, "?")) {
8  
        fS q = "Did you say anything?";
9  
        print(q);
10  
        showButtons(
11  
          "Yes", r { log(s, q, 'yes); whatDidYouSay(s); },
12  
          "No", r { log(s, q, 'no); print("Thanks"); });
13  
      } else {
14  
        fS q = "Did you say that?";
15  
        print(q);
16  
        showButtons(
17  
          "Yes", r { log(s, q, 'yes); print("Thanks"); },
18  
          "No", r { log(s, q, 'no); whatDidYouSay(s); });
19  
      }
20  
    });
21  
  }
22  
  
23  
  void log(S heard, S question, S answer) {
24  
    print("> " + upper(answer));
25  
    logStructure(programLogFile(), litorderedmap(+heard, +question, +answer));
26  
    hideButtons();
27  
  }
28  
  
29  
  void whatDidYouSay(fS heard) {
30  
    print("What did you say?");
31  
    final JTextField tf = jTextField(heard);
32  
    showButtons(textFieldAndButton(tf, "is what I said", voidfunc(S corrected) {
33  
      print("> I said " + quote(upper(corrected)));
34  
      logStructure(programLogFile(), litorderedmap(+heard, +corrected));
35  
      hideButtons();
36  
      print("Thanks");
37  
    }));
38  
    focus(tf);
39  
  }
40  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019363
Snippet name: Speech Recognition Confirmation [Did computer understand correctly?, Dyn Module]
Eternal ID of this version: #1019363/17
Text MD5: bf2d18c11964643642ac0fb22eb2e60d
Transpilation MD5: 2c7d6b095aab0c66803cca06d85067cf
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-05 00:12:59
Source code size: 1236 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 392 / 739
Version history: 16 change(s)
Referenced in: [show references]