Use AudioSystem on the audio settings page
This commit is contained in:
parent
cadcd72fad
commit
d8e2e69ca5
@ -17,11 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*global getOptionsContext, getOptionsMutable, settingsSaveOptions
|
/*global getOptionsContext, getOptionsMutable, settingsSaveOptions
|
||||||
AudioSourceUI, audioGetTextToSpeechVoice*/
|
AudioSystem, AudioSourceUI*/
|
||||||
|
|
||||||
let audioSourceUI = null;
|
let audioSourceUI = null;
|
||||||
|
let audioSystem = null;
|
||||||
|
|
||||||
async function audioSettingsInitialize() {
|
async function audioSettingsInitialize() {
|
||||||
|
audioSystem = new AudioSystem();
|
||||||
|
|
||||||
const optionsContext = getOptionsContext();
|
const optionsContext = getOptionsContext();
|
||||||
const options = await getOptionsMutable(optionsContext);
|
const options = await getOptionsMutable(optionsContext);
|
||||||
audioSourceUI = new AudioSourceUI.Container(
|
audioSourceUI = new AudioSourceUI.Container(
|
||||||
@ -100,16 +103,11 @@ function textToSpeechVoiceCompare(a, b) {
|
|||||||
function textToSpeechTest() {
|
function textToSpeechTest() {
|
||||||
try {
|
try {
|
||||||
const text = document.querySelector('#text-to-speech-voice-test').dataset.speechText || '';
|
const text = document.querySelector('#text-to-speech-voice-test').dataset.speechText || '';
|
||||||
const voiceURI = document.querySelector('#text-to-speech-voice').value;
|
const voiceUri = document.querySelector('#text-to-speech-voice').value;
|
||||||
const voice = audioGetTextToSpeechVoice(voiceURI);
|
|
||||||
if (voice === null) { return; }
|
|
||||||
|
|
||||||
const utterance = new SpeechSynthesisUtterance(text);
|
const audio = audioSystem.createTextToSpeechAudio({text, voiceUri});
|
||||||
utterance.lang = 'ja-JP';
|
audio.volume = 1.0;
|
||||||
utterance.voice = voice;
|
audio.play();
|
||||||
utterance.volume = 1.0;
|
|
||||||
|
|
||||||
speechSynthesis.speak(utterance);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// NOP
|
// NOP
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user