Fix System TTS on iOS

This commit is contained in:
Cohee
2023-06-09 12:33:28 +03:00
parent 3f79a066f6
commit 78724d95f7

View File

@ -1,3 +1,4 @@
import { isMobile } from "../../RossAscends-mods.js";
import { getPreviewString } from "./index.js";
export { SystemTtsProvider }
@ -112,6 +113,21 @@ class SystemTtsProvider {
console.info("Using default TTS Provider settings");
}
// iOS should only allows speech synthesis trigged by user interaction
if (isMobile()) {
let hasEnabledVoice = false;
document.addEventListener('click', () => {
if (hasEnabledVoice) {
return;
}
const utterance = new SpeechSynthesisUtterance('hi');
utterance.volume = 0;
speechSynthesis.speak(utterance);
hasEnabledVoice = true;
});
}
// Only accept keys defined in defaultSettings
this.settings = this.defaultSettings;