aboutsummaryrefslogtreecommitdiff
path: root/ext/js/media/text-to-speech-audio.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-27 12:48:14 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-27 12:48:14 -0500
commit4da4827bcbcdd1ef163f635d9b29416ff272b0bb (patch)
treea8a0f1a8befdb78a554e1be91f2c6059ca3ad5f9 /ext/js/media/text-to-speech-audio.js
parentfd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff)
Add JSDoc type annotations to project (rebased)
Diffstat (limited to 'ext/js/media/text-to-speech-audio.js')
-rw-r--r--ext/js/media/text-to-speech-audio.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/js/media/text-to-speech-audio.js b/ext/js/media/text-to-speech-audio.js
index ae717519..cd1205e5 100644
--- a/ext/js/media/text-to-speech-audio.js
+++ b/ext/js/media/text-to-speech-audio.js
@@ -17,13 +17,22 @@
*/
export class TextToSpeechAudio {
+ /**
+ * @param {string} text
+ * @param {SpeechSynthesisVoice} voice
+ */
constructor(text, voice) {
+ /** @type {string} */
this._text = text;
+ /** @type {SpeechSynthesisVoice} */
this._voice = voice;
+ /** @type {?SpeechSynthesisUtterance} */
this._utterance = null;
+ /** @type {number} */
this._volume = 1;
}
+ /** @type {number} */
get currentTime() {
return 0;
}
@@ -32,6 +41,7 @@ export class TextToSpeechAudio {
// NOP
}
+ /** @type {number} */
get volume() {
return this._volume;
}
@@ -43,6 +53,9 @@ export class TextToSpeechAudio {
}
}
+ /**
+ * @returns {Promise<void>}
+ */
async play() {
try {
if (this._utterance === null) {
@@ -59,6 +72,9 @@ export class TextToSpeechAudio {
}
}
+ /**
+ * @returns {void}
+ */
pause() {
try {
speechSynthesis.cancel();