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).

1  
!7
2  
3  
p-exp { serveHttpIfMain(8123); }
4  
5  
html {
6  
  ret htitle("Speech Output Test")
7  
    + p("Press F12 to open console")
8  
    + "Text to say: " + htextinput("text", id := "thetext", onKeyUp := [[if (event.keyCode == 13) { say(document.getElementById("thetext").value); return false; }]])
9  
    + hjavascript([[
10  
      function say(text) {
11  
        console.log("Saying: " + text);
12  
        var u = new SpeechSynthesisUtterance(text);
13  
        u.volume = 0.25; // quarter volume
14  
        u.onstart = function() { console.log("Utterance start"); };
15  
        u.onend = function() { console.log("Utterance end"); };
16  
        u.onboundary = function() { console.log("Utterance boundary"); };
17  
        u.onerror = function() { console.log("Utterance error"); };
18  
        window.speechSynthesis.speak(u);
19  
      }
20  
      
21  
      console.log("Voices: " + window.speechSynthesis.getVoices().length);
22  
      var speaking = true;
23  
      function checkStatus() {
24  
        var s = window.speechSynthesis.speaking;
25  
        if (s != speaking)
26  
          if (s)
27  
            console.log("Speaking");
28  
          else
29  
            console.log("Not speaking");
30  
        speaking = s;
31  
        setTimeout(checkStatus, 200);
32  
      }
33  
      checkStatus();
34  
    ]]);
35  
}

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: 142 / 672
Version history: 7 change(s)
Referenced in: [show references]