JavaScript speechSynthesis.speak() without user activation is no longer allowed since M71

stepozer

I used speechSynthesis API in this way:

speechSynthesis.speak(new SpeechSynthesisUtterance("hello world"));

But right now I get error after update Google Chrome:

[Deprecation] speechSynthesis.speak() without user activation is no longer allowed since M71, around December 2018. See https://www.chromestatus.com/feature/5687444770914304 for more details speechSynthesisMessage @ application-2c16c437c2795ae01c0a8852e5f8da58dad99d6e17814a31f1eea19922c5ebd2.js:147

How I can fix this issue and ask permission?

Kaiido

This is part of Chrome's new policies regarding making sound from web-pages.
You simply need your user to provide an user-gesture (for which you can find a list here) during the lifetime of the parent document (i.e the event may long be dead, as long as the user ever interacted with the page).

Note that these events can even traverse frames, so for instance, in StackOverflow, the simple fact that you do have to click on the "Run" button will make the inner frame allowed to execute this code:

const ut = new SpeechSynthesisUtterance('No warning should arise');
speechSynthesis.speak(ut);

And in your code, you simply have to provide some kind of an UI that will ensure your users have interacted with the page before you call this method (e.g a button / toggle will do perfectly).

Эта статья взята из Интернета, укажите источник при перепечатке.

Если есть какие-либо нарушения, пожалуйста, свяжитесь с[email protected] Удалить.

Отредактировано в
0

я говорю два предложения

0обзор
Войти в системуУчаствуйте в комментариях

Статьи по теме

window.speechSynthesis.speak не будет говорить, если ни одна другая команда не останется неполной

Код JavaScript для window.speechSynthesis не работает с localhost

Вопрос о том, разрешено ли SpeechSynthesis работать без взаимодействия с пользователем

SpeechSynthesisСписок языков?

SpeechSynthesis - использование голоса, отличного от родного

Изменение голоса SpeechSynthesis не работает

Синхронное выполнение в javascript с SpeakSynthesis.speak ()

Странные свойства класса "Speak"

Isolate no longer works since addition of eventReactive and observeEvent?

Without JavaScript, can I show a different text when a longer one won't fit?

SpeechSynthesis не работает в мобильном Safari, хотя он поддерживается

Javascript multiple script tag are allowed?

WooCommerce coupon usage restriction by allowed user roles

В чем разница между SpeechSynthesis и chrome.tts

SpeechSynthesis не определен в Android, но определен в Electron (Windows)

SpeechRecognition и SpeechSynthesis в TypeScript

SpeechSynthesis API onend callback не работает

SpeechSynthesis.getVoices () возвращает пустой массив в Windows

SpeechSynthesis перестает работать после первого произнесения в FireFox, но работает в Chrome

Как использовать Apple SpeechSynthesis AudioUnit с AudioKit?

Cant extract table data since table name "User" is a reserved name

Every UIAlertController disappear automatically before user responds - since iOS 13

Cannot knit Rmd file since I changed the name of User directory

Я продолжаю получать сообщение об ошибке ($ __ is not allowed) при проверке правильности объекта

C Multithreading without pthreads: "The program no longer exists" Seg fault

Возобновление приостановленной речи с помощью SpeechSynthesis.resume () на Chrome Android не работает

SpeechSynthesis.getVoices () - пустой массив в Chromium Fedora

Как сохранить звук SpeechSynthesis в файл Mp3 в приложении UWP

Почему SpeechSynthesis.getVoices () в Google Chrome возвращает пустой список?

TOP список

  1. 1

    Распределение Рэлея Curve_fit на Python

  2. 2

    Как не использовать HttpClient с ЛЮБЫМ сертификата SSL, независимо от того, как «плохо» это

  3. 3

    Modbus Python Schneider PM5300

  4. 4

    (fields.E300) Поле определяет связь с моделью, которая либо не установлена, либо является абстрактной.

  5. 5

    Elasticsearch - Нечеткий поиск не дает предложения

  6. 6

    TypeError: store.getState não é uma função. (Em 'store.getState ()', 'store.getState' é indefinido, como posso resolver esse problema?

  7. 7

    Перебирайте несколько столбцов в фрейме данных Panda и находите уникальные значения подсчета

  8. 8

    Merging legends in plotly subplot

  9. 9

    SQL Вычтите две строки друг от друга в одном столбце, чтобы получить результат

  10. 10

    Автозаполнение с Java, Redis, Elastic Search, Монго

  11. 11

    Vue js CLI 2 импортирует и использует плагин javascript

  12. 12

    Метод ошибки Illuminate \\ Database \\ Eloquent \\ Collection :: save не существует. в Laravel

  13. 13

    Single legend for Plotly subplot for line plots created from two data frames in R

  14. 14

    В чем разница между CRC-16 / CCITT-FALSE и CRC-16 / X-25?

  15. 15

    Ленивое объединение FPU в Cortex-M4F

  16. 16

    Как очистить или очистить StringBuilder?

  17. 17

    PyQt5 не работает как «подходящий UI Toolkit» для Mayavi с Python 3.6.

  18. 18

    В типе Observable <unknown> отсутствуют следующие свойства из типа Promise <any>.

  19. 19

    Vue 2 / Vue CLI 3: создание асинхронных однофайловых компонентов

  20. 20

    Текущая ветка не настроена для извлечения В конфигурации не найдено значение для ключа branch.master.merge

  21. 21

    Проблемы со сборкой Python Image Registration Toolkit

популярныйтег

файл