tts.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // This file was generated by:
  5. // tools/json_schema_compiler/compiler.py.
  6. // NOTE: The format of types has changed. 'FooType' is now
  7. // 'chrome.tts.FooType'.
  8. // Please run the closure compiler before committing changes.
  9. // See https://chromium.googlesource.com/chromium/src/+/master/docs/closure_compilation.md
  10. /** @fileoverview Externs generated from namespace: tts */
  11. /** @const */
  12. chrome.tts = {};
  13. /**
  14. * @enum {string}
  15. * @see https://developer.chrome.com/extensions/tts#type-EventType
  16. */
  17. chrome.tts.EventType = {
  18. START: 'start',
  19. END: 'end',
  20. WORD: 'word',
  21. SENTENCE: 'sentence',
  22. MARKER: 'marker',
  23. INTERRUPTED: 'interrupted',
  24. CANCELLED: 'cancelled',
  25. ERROR: 'error',
  26. PAUSE: 'pause',
  27. RESUME: 'resume',
  28. };
  29. /**
  30. * @enum {string}
  31. * @see https://developer.chrome.com/extensions/tts#type-VoiceGender
  32. */
  33. chrome.tts.VoiceGender = {
  34. MALE: 'male',
  35. FEMALE: 'female',
  36. };
  37. /**
  38. * The speech options for the TTS engine.
  39. * @constructor
  40. * @private
  41. * @see https://developer.chrome.com/extensions/tts#type-TtsOptions
  42. */
  43. chrome.tts.TtsOptions = function() {};
  44. /**
  45. * If true, enqueues this utterance if TTS is already in progress. If false (the default), interrupts any current speech and flushes the speech queue before speaking this new utterance.
  46. * @type {(boolean|undefined)}
  47. * @see https://developer.chrome.com/extensions/tts#type-enqueue
  48. */
  49. chrome.tts.TtsOptions.prototype.enqueue;
  50. /**
  51. * The name of the voice to use for synthesis. If empty, uses any available voice.
  52. * @type {(string|undefined)}
  53. * @see https://developer.chrome.com/extensions/tts#type-voiceName
  54. */
  55. chrome.tts.TtsOptions.prototype.voiceName;
  56. /**
  57. * The extension ID of the speech engine to use, if known.
  58. * @type {(string|undefined)}
  59. * @see https://developer.chrome.com/extensions/tts#type-extensionId
  60. */
  61. chrome.tts.TtsOptions.prototype.extensionId;
  62. /**
  63. * The language to be used for synthesis, in the form <em>language</em>-<em>region</em>. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'.
  64. * @type {(string|undefined)}
  65. * @see https://developer.chrome.com/extensions/tts#type-lang
  66. */
  67. chrome.tts.TtsOptions.prototype.lang;
  68. /**
  69. * Gender of voice for synthesized speech.
  70. * @type {(!chrome.tts.VoiceGender|undefined)}
  71. * @see https://developer.chrome.com/extensions/tts#type-gender
  72. */
  73. chrome.tts.TtsOptions.prototype.gender;
  74. /**
  75. * Speaking rate relative to the default rate for this voice. 1.0 is the default rate, normally around 180 to 220 words per minute. 2.0 is twice as fast, and 0.5 is half as fast. Values below 0.1 or above 10.0 are strictly disallowed, but many voices will constrain the minimum and maximum rates further&mdash;for example a particular voice may not actually speak faster than 3 times normal even if you specify a value larger than 3.0.
  76. * @type {(number|undefined)}
  77. * @see https://developer.chrome.com/extensions/tts#type-rate
  78. */
  79. chrome.tts.TtsOptions.prototype.rate;
  80. /**
  81. * Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 corresponds to a voice's default pitch.
  82. * @type {(number|undefined)}
  83. * @see https://developer.chrome.com/extensions/tts#type-pitch
  84. */
  85. chrome.tts.TtsOptions.prototype.pitch;
  86. /**
  87. * Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest, with a default of 1.0.
  88. * @type {(number|undefined)}
  89. * @see https://developer.chrome.com/extensions/tts#type-volume
  90. */
  91. chrome.tts.TtsOptions.prototype.volume;
  92. /**
  93. * The TTS event types the voice must support.
  94. * @type {(!Array<string>|undefined)}
  95. * @see https://developer.chrome.com/extensions/tts#type-requiredEventTypes
  96. */
  97. chrome.tts.TtsOptions.prototype.requiredEventTypes;
  98. /**
  99. * The TTS event types that you are interested in listening to. If missing, all event types may be sent.
  100. * @type {(!Array<string>|undefined)}
  101. * @see https://developer.chrome.com/extensions/tts#type-desiredEventTypes
  102. */
  103. chrome.tts.TtsOptions.prototype.desiredEventTypes;
  104. /**
  105. * This function is called with events that occur in the process of speaking the
  106. * utterance.
  107. * @param {!chrome.tts.TtsEvent} event The update event from the text-to-speech
  108. * engine indicating the status of this utterance.
  109. * @see https://developer.chrome.com/extensions/tts#method-onEvent
  110. */
  111. chrome.tts.TtsOptions.prototype.onEvent = function(event) {};
  112. /**
  113. * An event from the TTS engine to communicate the status of an utterance.
  114. * @typedef {{
  115. * type: !chrome.tts.EventType,
  116. * charIndex: (number|undefined),
  117. * errorMessage: (string|undefined),
  118. * srcId: (number|undefined),
  119. * isFinalEvent: (boolean|undefined),
  120. * length: (number|undefined)
  121. * }}
  122. * @see https://developer.chrome.com/extensions/tts#type-TtsEvent
  123. */
  124. chrome.tts.TtsEvent;
  125. /**
  126. * A description of a voice available for speech synthesis.
  127. * @typedef {{
  128. * voiceName: (string|undefined),
  129. * lang: (string|undefined),
  130. * gender: (!chrome.tts.VoiceGender|undefined),
  131. * remote: (boolean|undefined),
  132. * extensionId: (string|undefined),
  133. * eventTypes: (!Array<!chrome.tts.EventType>|undefined)
  134. * }}
  135. * @see https://developer.chrome.com/extensions/tts#type-TtsVoice
  136. */
  137. chrome.tts.TtsVoice;
  138. /**
  139. * Speaks text using a text-to-speech engine.
  140. * @param {string} utterance The text to speak, either plain text or a complete,
  141. * well-formed SSML document. Speech engines that do not support SSML will
  142. * strip away the tags and speak the text. The maximum length of the text is
  143. * 32,768 characters.
  144. * @param {!chrome.tts.TtsOptions=} options The speech options.
  145. * @param {function(): void=} callback Called right away, before speech
  146. * finishes. Check $(ref:runtime.lastError) to make sure there were no
  147. * errors. Use options.onEvent to get more detailed feedback.
  148. * @see https://developer.chrome.com/extensions/tts#method-speak
  149. */
  150. chrome.tts.speak = function(utterance, options, callback) {};
  151. /**
  152. * Stops any current speech and flushes the queue of any pending utterances. In
  153. * addition, if speech was paused, it will now be un-paused for the next call to
  154. * speak.
  155. * @see https://developer.chrome.com/extensions/tts#method-stop
  156. */
  157. chrome.tts.stop = function() {};
  158. /**
  159. * Pauses speech synthesis, potentially in the middle of an utterance. A call to
  160. * resume or stop will un-pause speech.
  161. * @see https://developer.chrome.com/extensions/tts#method-pause
  162. */
  163. chrome.tts.pause = function() {};
  164. /**
  165. * If speech was paused, resumes speaking where it left off.
  166. * @see https://developer.chrome.com/extensions/tts#method-resume
  167. */
  168. chrome.tts.resume = function() {};
  169. /**
  170. * Checks whether the engine is currently speaking. On Mac OS X, the result is
  171. * true whenever the system speech engine is speaking, even if the speech wasn't
  172. * initiated by Chrome.
  173. * @param {function(boolean): void=} callback
  174. * @see https://developer.chrome.com/extensions/tts#method-isSpeaking
  175. */
  176. chrome.tts.isSpeaking = function(callback) {};
  177. /**
  178. * Gets an array of all available voices.
  179. * @param {function(!Array<!chrome.tts.TtsVoice>): void=} callback
  180. * @see https://developer.chrome.com/extensions/tts#method-getVoices
  181. */
  182. chrome.tts.getVoices = function(callback) {};
  183. /**
  184. * Used to pass events back to the function calling speak().
  185. * @type {!ChromeEvent}
  186. * @see https://developer.chrome.com/extensions/tts#event-onEvent
  187. */
  188. chrome.tts.onEvent;