Detect Speak function

I uses built in speak function in one of my android phone, which the device’s didn’t support. May I know how should I detect and hence disable speak. There is a err :Uncaught type err, cannot set properties of undefined(setting text).
Best rdgs, tst

In that button, I also have localStorage. I wonder which is the culprit. Remote debugging doesn’t shows any err…

Let me do some homework first when I reached home tonight…

Below is my code, I suspect my Samsung tab3 is unstable for my app, as sometimes, it even restarts the phone before my app finishes installs.

Dim kl = 0
Dim soundplay = 0

Function Button9_onclick()
     Try
  localStorage.private = "test"
Catch err
   MsgBox "Please turn Private Browsing off" 
End Try 
  kl = 0
 
  soundplay = 0
  kl = localStorage.getItem("keysoundplay") 'creates localStorage.key with defined value  
  If kl = 0 Then
  'on
  soundplay = 1
  'MsgBox "turn on sound"
  
  Dim voice
  If InStr(navigator.vendor,"Apple") Then voice = "Alex"
  If InStr(navigator.vendor,"Google") Then voice = "Google UK English Male"
  'Speak("Hello World", voice)
  Speak("Cheers! s Fighter")
  
  Button9.value = "sound on"
  ElseIf kl = 1 Then
  'off
  soundplay = 0
  'MsgBox "turn off sound"
  Button9.value = "sound off"
  Else
  'on
  soundplay = 1
  MsgBox "turn on sound"
  Button9.value = "sound on"
  End If
  localStorage.setItem("keysoundplay",soundplay) 'creates localStorage.key with defined value  
End Function

But my 2 other phone also have similar err?!

The Speak function using the speechSynthesis feature of JavaScript.

Here’s some JavaScript code to see if it exists:

if (typeof(speechSynthesis) != 'undefined' && speechSynthesis != null) {
...
}

Bravo,! all is well now.my note3 can ‘playtone’ , cannot ‘speak’. Thanks for the code, it solves everything…
Below is my revised code.

  
JavaScript
  var voice;
  voice = "";

if ( typeof(speechSynthesis) != "undefined" && (speechSynthesis != null) ) {
 
  if (InStr(navigator.vendor, "Apple")) {
   voice = "Alex";}
  if (InStr(navigator.vendor, "Google")) {
   voice = "Google UK English Male";}
   
  Speak("Cheers! s Fighter",voice);
  }

End JavaScript  

This morning, a new err occured:deprecated feature used, speech Synthesis. speak() without user activation is deprecated and will be removed…

Searching the Web, shows that the usual way of using speak is gone, as it were abuse at numerous site. Hopefully, there will be a new kind of speak function with user activation coming soon…

Here’s an article about it: