Use AudioSystem on the audio settings page

This commit is contained in:
toasted-nutbread 2020-03-07 13:26:15 -05:00
parent cadcd72fad
commit d8e2e69ca5

View File

@ -17,11 +17,14 @@
*/
/*global getOptionsContext, getOptionsMutable, settingsSaveOptions
AudioSourceUI, audioGetTextToSpeechVoice*/
AudioSystem, AudioSourceUI*/
let audioSourceUI = null;
let audioSystem = null;
async function audioSettingsInitialize() {
audioSystem = new AudioSystem();
const optionsContext = getOptionsContext();
const options = await getOptionsMutable(optionsContext);
audioSourceUI = new AudioSourceUI.Container(
@ -100,16 +103,11 @@ function textToSpeechVoiceCompare(a, b) {
function textToSpeechTest() {
try {
const text = document.querySelector('#text-to-speech-voice-test').dataset.speechText || '';
const voiceURI = document.querySelector('#text-to-speech-voice').value;
const voice = audioGetTextToSpeechVoice(voiceURI);
if (voice === null) { return; }
const voiceUri = document.querySelector('#text-to-speech-voice').value;
const utterance = new SpeechSynthesisUtterance(text);
utterance.lang = 'ja-JP';
utterance.voice = voice;
utterance.volume = 1.0;
speechSynthesis.speak(utterance);
const audio = audioSystem.createTextToSpeechAudio({text, voiceUri});
audio.volume = 1.0;
audio.play();
} catch (e) {
// NOP
}