2

I have created a Samsung smart-tv app using javascript and now I want to disable the TTS in this app but don't know how I can do this please help.

I have tried using window.speechSynthesis but it is not working don't know why. currently what i have done is when window load i call an init() function

function init(){
    if ('speechSynthesis' in window) {
              var synthesis = window.speechSynthesis;
              synthesis.cancel();

            } else {
              console.log('Text-to-speech not supported.');
            }

}

but it does not work and so finally i want to disable the feature of Text to speech from my application

Nitin tiwari
  • 664
  • 1
  • 8
  • 23

2 Answers2

2

Please have a good reason to do so, disabling voice over is never a good choice. You are basically removing access to people with visual impairments and even if you did a bad job at making your app accessible that will always be better than just disabling it.

Having said that, there's no way to disable voice over using javascript but you can disable it by adding the following tag inside <widget> in your config.xml file:

<tizen:metadata key="http://samsung.com/tv/metadata/use.voiceguide" value="false" />
Arkanoid
  • 1,165
  • 8
  • 17
  • Thank you for this reply, it really helped me out when developing an app that the Samsung TTS service doesn't support the UI language of the app – Sverrir Sigmundarson Mar 04 '23 at 20:59
  • here's the docs if anyone is looking https://developer.samsung.com/smarttv/develop/guides/fundamentals/configuring-tv-applications.html – Lizozom Apr 24 '23 at 19:54
1

You can't disable that feature. The SpeechSynthesis api is if you want to add extra functionality, not for disabling the native feature (which can only be disabled by users of your app from the TV/browser settings).

As written here: https://developer.samsung.com/smarttv/develop/legacy-platform-library/tv-functionality/accessibility.html

If user turns on Accessibility option for TTS in menu, TTS will read contents of HTML elements automatically.

You can try 2 things (which might not work):

  1. Run every 1s (or more often) speechSynthesis.cancel() in a setInterval (I'm not sure this will stop the native TTS of the TV though).

setInterval(() => window.speechSynthesis.cancel(), 1000)

  1. Replace window.speechSynthesis.speak with an empty function at the beginning of your app (considering Samsung TV uses this for speaking).

window.speechSynthesis.speak = () => {}

tudor.gergely
  • 4,800
  • 1
  • 16
  • 22