diff options
Diffstat (limited to 'ext/js/media/text-to-speech-audio.js')
-rw-r--r-- | ext/js/media/text-to-speech-audio.js | 16 |
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(); |