From 8e2252215331f28d35bc4d383c6f8c06cd3de3f6 Mon Sep 17 00:00:00 2001 From: tomivm Date: Mon, 13 Mar 2023 13:27:46 -0300 Subject: [PATCH 1/2] Create constants to differentiate the user browser --- src/constants.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/constants.js b/src/constants.js index b01aa2e04..43de0c925 100644 --- a/src/constants.js +++ b/src/constants.js @@ -32,6 +32,16 @@ export const ADSENSE_CLIENT = 'ca-pub-7162313874228987'; export const ADD_SLOT_SETTINGS_TOP = '5250438005'; -export const IS_BROWSING_FROM_APPLE = /iPad|iPhone|iPod|Mac/.test( - navigator.userAgent -); +const userAgent = navigator.userAgent; + +export const IS_BROWSING_FROM_APPLE = /iPad|iPhone|iPod|Mac/.test(userAgent); + +export const IS_BROWSING_FROM_APPLE_TOUCH = + IS_BROWSING_FROM_APPLE && 'ontouchend' in document; + +export const IS_BROWSING_FROM_SAFARI = + userAgent.indexOf('Safari') > -1 && + userAgent.indexOf('Chrome') === -1 && + !navigator.userAgent.match(/crios/i) && + !navigator.userAgent.match(/fxios/i) && + !navigator.userAgent.match(/Opera|OPT\//); From af2aebcc2b7c675779fe742f65c956585a4a56ae Mon Sep 17 00:00:00 2001 From: tomivm Date: Mon, 13 Mar 2023 13:31:35 -0300 Subject: [PATCH 2/2] Cancel local synth before speak only on Safari or Apple touch devices --- src/providers/SpeechProvider/tts.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/providers/SpeechProvider/tts.js b/src/providers/SpeechProvider/tts.js index f847c2f22..3568e48ad 100644 --- a/src/providers/SpeechProvider/tts.js +++ b/src/providers/SpeechProvider/tts.js @@ -4,7 +4,9 @@ import API from '../../api'; import { AZURE_SPEECH_SERVICE_REGION, AZURE_SPEECH_SUBSCR_KEY, - IS_BROWSING_FROM_APPLE + IS_BROWSING_FROM_APPLE, + IS_BROWSING_FROM_APPLE_TOUCH, + IS_BROWSING_FROM_SAFARI } from '../../constants'; import { getStore } from '../../store'; @@ -267,7 +269,8 @@ const tts = { msg.rate = rate; msg.volume = volume; msg.onend = onend; - synth.cancel(); + if (IS_BROWSING_FROM_SAFARI || IS_BROWSING_FROM_APPLE_TOUCH) + synth.cancel(); synth.speak(msg); } }