Browse Source

tts default sound fix

master
vampirefrog 1 year ago
parent
commit
25ef9e5c5a
  1. 39
      static/tts.js

39
static/tts.js

@ -63,22 +63,20 @@ function removeDiv(id) {
}
function playSound(s, next) {
console.log('playSound', s);
s.on('ready', function(event) {
s.play();
});
s.on('ended', function(event) {
if(next) next.call(this);
if(next) next.call(this, null);
});
s.on('error', function(event) {
console.log('error playing sound', event);
if(next) next.call(this);
s.on('error', function(err) {
if(next) next.call(this, err||true);
});
if(s.readyState == 'ready') {
s.play();
} else if(s.readyState == 'error' || s.readyState == 'ended') {
if(next) next.call(this);
if(next) next.call(this, true);
}
}
@ -176,9 +174,14 @@ function appendChat(chat) {
},
(item) => {
highlightDiv(item.id);
playSound(item.data.speechSound, () => {
playSound(item.data.sound, () => {
playSound(defaultSound, () => {
playSound(item.data.speechSound, (err) => {
playSound(item.data.sound, (err) => {
if(!err) {
endSound(item);
return;
}
playSound(defaultSound, (err) => {
endSound(item);
});
});
@ -193,8 +196,13 @@ function appendChat(chat) {
},
(item) => {
highlightDiv(item.id);
playSound(item.data.speechSound, () => {
playSound(defaultSound, () => {
playSound(item.data.speechSound, (err) => {
if(!err) {
endSound(item);
return;
}
playSound(defaultSound, (err) => {
endSound(item);
});
});
@ -212,8 +220,13 @@ function appendChat(chat) {
},
(item) => {
highlightDiv(item.id);
playSound(item.data.sound, () => {
playSound(defaultSound, () => {
playSound(item.data.sound, (err, sound) => {
if(!err) {
endSound(item);
return;
}
playSound(defaultSound, (err, sound) => {
endSound(item);
});
});

Loading…
Cancel
Save