diff options
| author | Darius Jahandarie <djahandarie@gmail.com> | 2023-12-06 03:53:16 +0000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-06 03:53:16 +0000 | 
| commit | bd5bc1a5db29903bc098995cd9262c4576bf76af (patch) | |
| tree | c9214189e0214480fcf6539ad1c6327aef6cbd1c /ext/js/media/text-to-speech-audio.js | |
| parent | fd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff) | |
| parent | 23e6fb76319c9ed7c9bcdc3efba39bc5dd38f288 (diff) | |
Merge pull request #339 from toasted-nutbread/type-annotations
Type annotations
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(); |