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

35
LINES

< > BotCompany Repo | #1027702 // Test WebKit SpeechSynthesis and .speaking attribute

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (9529L/70K).

!7

p-exp { serveHttpIfMain(8123); }

html {
  ret htitle("Speech Output Test")
    + p("Press F12 to open console")
    + "Text to say: " + htextinput("text", id := "thetext", onKeyUp := [[if (event.keyCode == 13) { say(document.getElementById("thetext").value); return false; }]])
    + hjavascript([[
      function say(text) {
        console.log("Saying: " + text);
        var u = new SpeechSynthesisUtterance(text);
        u.volume = 0.25; // quarter volume
        u.onstart = function() { console.log("Utterance start"); };
        u.onend = function() { console.log("Utterance end"); };
        u.onboundary = function() { console.log("Utterance boundary"); };
        u.onerror = function() { console.log("Utterance error"); };
        window.speechSynthesis.speak(u);
      }
      
      console.log("Voices: " + window.speechSynthesis.getVoices().length);
      var speaking = true;
      function checkStatus() {
        var s = window.speechSynthesis.speaking;
        if (s != speaking)
          if (s)
            console.log("Speaking");
          else
            console.log("Not speaking");
        speaking = s;
        setTimeout(checkStatus, 200);
      }
      checkStatus();
    ]]);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

-
Snippet ID: #1027702
Snippet name: Test WebKit SpeechSynthesis and .speaking attribute
Eternal ID of this version: #1027702/8
Text MD5: d3baba046f64902079ca1770666ac5de
Transpilation MD5: 77b450201e16396ba2c7aba837820f67
Author: stefan
Category: javax / html / speech
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-02 20:13:25
Source code size: 1248 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 245 / 922
Version history: 7 change(s)
Referenced in: