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

42
LINES

< > BotCompany Repo | #1009223 // Chrome Speech Recognition Test [WORKS]

JavaX source code [tags: butter use-pretranspiled] - run with: x30.jar - homepage

Libraryless. Click here for Pure Java version (4357L/32K/91K).

!7

p {
  if (isMainProgram()) serveHttpAndOpenBrowser();
}

html {
  ret h3("Chrome Speech Recognition Test")
    + loadJQuery()
    + hdiv("Results come here", id := 'results, style := "margin: 10px")
  + hjavascript([[
    var recognition = new webkitSpeechRecognition();
    recognition.lang = "en-US";
    
    recognition.onerror = function(event) { 
      console.log('Speech recognition error detected: ' + event.error);
      console.log('Additional information: ' + event.message);
      $("#results").html("Error.");
      started = false; $("#btn").html("Start recognition");
    }
    
    recognition.onresult = function(event) { 
      var result = event.results[0];
      var transcript = result[0].transcript;
      $("#results").html("Transcript: " + transcript);
      started = false; $("#btn").html("Start recognition");
    }
    
    var started = false;
    
    function startOrStop() {
      if (started) {
        recognition.stop();
        started = false; $("#btn").html("Start recognition");
      } else {
        recognition.start();
        started = true; $("#btn").html("Stop recognition");
      }
    }
  ]])
    + tag('button, "Start recognition", onclick := "startOrStop()", type := 'button, id := 'btn);
}

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: #1009223
Snippet name: Chrome Speech Recognition Test [WORKS]
Eternal ID of this version: #1009223/15
Text MD5: 549828d3d2cd5933d7ef3384a3275ca7
Transpilation MD5: 9176d0be1683f8c83789561853ab2b09
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-24 18:23:44
Source code size: 1287 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 487 / 4128
Version history: 14 change(s)
Referenced in: [show references]