/* * Copyright (C) 2019 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ let audioSourceUI = null; async function audioSettingsInitialize() { const optionsContext = getOptionsContext(); const options = await apiOptionsGet(optionsContext); audioSourceUI = new AudioSourceUI.Container(options.audio.sources, $('.audio-source-list'), $('.audio-source-add')); audioSourceUI.save = () => settingsSaveOptions(); textToSpeechInitialize(); } function textToSpeechInitialize() { if (typeof speechSynthesis === 'undefined') { return; } speechSynthesis.addEventListener('voiceschanged', () => updateTextToSpeechVoices(), false); updateTextToSpeechVoices(); $('#text-to-speech-voice-test').on('click', () => textToSpeechTest()); } function updateTextToSpeechVoices() { const voices = Array.prototype.map.call(speechSynthesis.getVoices(), (voice, index) => ({voice, index})); voices.sort(textToSpeechVoiceCompare); if (voices.length > 0) { $('#text-to-speech-voice-container').css('display', ''); } const select = $('#text-to-speech-voice'); select.empty(); select.append($('