summaryrefslogtreecommitdiff
path: root/ext/mixed/js/text-to-speech-audio.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-22 22:10:27 -0500
committerGitHub <noreply@github.com>2021-01-22 22:10:27 -0500
commit7fbfef513d1336a883968f319c7001b4bb04876d (patch)
treedf3098aee59805822d2e3028afad9df8d509104d /ext/mixed/js/text-to-speech-audio.js
parenta51a591c404e365bc1fca657bb26c04d165f400b (diff)
Display audio update (#1291)
* Move createExpressionAudio to DisplayAudio * Move createAudioFromInfo to DisplayAudio * Update TextToSpeechAudio
Diffstat (limited to 'ext/mixed/js/text-to-speech-audio.js')
-rw-r--r--ext/mixed/js/text-to-speech-audio.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/mixed/js/text-to-speech-audio.js b/ext/mixed/js/text-to-speech-audio.js
index 69244514..a32916f4 100644
--- a/ext/mixed/js/text-to-speech-audio.js
+++ b/ext/mixed/js/text-to-speech-audio.js
@@ -17,8 +17,8 @@
class TextToSpeechAudio {
constructor(text, voice) {
- this.text = text;
- this.voice = voice;
+ this._text = text;
+ this._voice = voice;
this._utterance = null;
this._volume = 1;
}
@@ -26,6 +26,7 @@ class TextToSpeechAudio {
get currentTime() {
return 0;
}
+
set currentTime(value) {
// NOP
}
@@ -33,6 +34,7 @@ class TextToSpeechAudio {
get volume() {
return this._volume;
}
+
set volume(value) {
this._volume = value;
if (this._utterance !== null) {
@@ -43,10 +45,10 @@ class TextToSpeechAudio {
async play() {
try {
if (this._utterance === null) {
- this._utterance = new SpeechSynthesisUtterance(this.text || '');
+ this._utterance = new SpeechSynthesisUtterance(typeof this._text === 'string' ? this._text : '');
this._utterance.lang = 'ja-JP';
this._utterance.volume = this._volume;
- this._utterance.voice = this.voice;
+ this._utterance.voice = this._voice;
}
speechSynthesis.cancel();