ttsEngine.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // Copyright 2021 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.ttsEngine.FooType'.
  8. // Please run the closure compiler before committing changes.
  9. // See
  10. // https://chromium.googlesource.com/chromium/src/+/main/docs/closure_compilation.md
  11. /** @fileoverview Externs generated from namespace: ttsEngine */
  12. /** @const */
  13. chrome.ttsEngine = {};
  14. /**
  15. * @enum {string}
  16. * @see https://developer.chrome.com/extensions/ttsEngine#type-VoiceGender
  17. */
  18. chrome.ttsEngine.VoiceGender = {
  19. MALE: 'male',
  20. FEMALE: 'female',
  21. };
  22. /**
  23. * Options specified to the tts.speak() method.
  24. * @typedef {{
  25. * voiceName: (string|undefined),
  26. * lang: (string|undefined),
  27. * gender: (!chrome.ttsEngine.VoiceGender|undefined),
  28. * rate: (number|undefined),
  29. * pitch: (number|undefined),
  30. * volume: (number|undefined)
  31. * }}
  32. * @see https://developer.chrome.com/extensions/ttsEngine#type-SpeakOptions
  33. */
  34. chrome.ttsEngine.SpeakOptions;
  35. /**
  36. * Contains the audio stream format expected to be produced by an engine.
  37. * @typedef {{
  38. * sampleRate: number,
  39. * bufferSize: number
  40. * }}
  41. * @see https://developer.chrome.com/extensions/ttsEngine#type-AudioStreamOptions
  42. */
  43. chrome.ttsEngine.AudioStreamOptions;
  44. /**
  45. * Parameters containing an audio buffer and associated data.
  46. * @typedef {{
  47. * audioBuffer: Float32Array,
  48. * charIndex: (number|undefined),
  49. * isLastBuffer: (boolean|undefined)
  50. * }}
  51. * @see https://developer.chrome.com/extensions/ttsEngine#type-AudioBuffer
  52. */
  53. chrome.ttsEngine.AudioBuffer;
  54. /**
  55. * Called by an engine to update its list of voices. This list overrides any
  56. * voices declared in this extension's manifest.
  57. * @param {!Array<!chrome.tts.TtsVoice>} voices Array of
  58. * $(ref:tts.TtsVoice) objects representing the available voices for speech
  59. * synthesis.
  60. * @see https://developer.chrome.com/extensions/ttsEngine#method-updateVoices
  61. */
  62. chrome.ttsEngine.updateVoices = function(voices) {};
  63. /**
  64. * Routes a TTS event from a speech engine to a client.
  65. * @param {number} requestId
  66. * @param {!chrome.tts.TtsEvent} event The update event from the
  67. * text-to-speech engine indicating the status of this utterance.
  68. * @see https://developer.chrome.com/extensions/ttsEngine#method-sendTtsEvent
  69. */
  70. chrome.ttsEngine.sendTtsEvent = function(requestId, event) {};
  71. /**
  72. * Routes TTS audio from a speech engine to a client.
  73. * @param {number} requestId
  74. * @param {!chrome.ttsEngine.AudioBuffer} audio An audio buffer from the
  75. * text-to-speech engine.
  76. * @see https://developer.chrome.com/extensions/ttsEngine#method-sendTtsAudio
  77. */
  78. chrome.ttsEngine.sendTtsAudio = function(requestId, audio) {};
  79. /**
  80. * Called when the user makes a call to tts.speak() and one of the voices from
  81. * this extension's manifest is the first to match the options object.
  82. * @type {!ChromeEvent}
  83. * @see https://developer.chrome.com/extensions/ttsEngine#event-onSpeak
  84. */
  85. chrome.ttsEngine.onSpeak;
  86. /**
  87. * Called when the user makes a call to tts.speak() and one of the voices from
  88. * this extension's manifest is the first to match the options object. Differs
  89. * from ttsEngine.onSpeak in that Chrome provides audio playback services and
  90. * handles dispatching tts events.
  91. * @type {!ChromeEvent}
  92. * @see https://developer.chrome.com/extensions/ttsEngine#event-onSpeakWithAudioStream
  93. */
  94. chrome.ttsEngine.onSpeakWithAudioStream;
  95. /**
  96. * Fired when a call is made to tts.stop and this extension may be in the middle
  97. * of speaking. If an extension receives a call to onStop and speech is already
  98. * stopped, it should do nothing (not raise an error). If speech is in the
  99. * paused state, this should cancel the paused state.
  100. * @type {!ChromeEvent}
  101. * @see https://developer.chrome.com/extensions/ttsEngine#event-onStop
  102. */
  103. chrome.ttsEngine.onStop;
  104. /**
  105. * Optional: if an engine supports the pause event, it should pause the current
  106. * utterance being spoken, if any, until it receives a resume event or stop
  107. * event. Note that a stop event should also clear the paused state.
  108. * @type {!ChromeEvent}
  109. * @see https://developer.chrome.com/extensions/ttsEngine#event-onPause
  110. */
  111. chrome.ttsEngine.onPause;
  112. /**
  113. * Optional: if an engine supports the pause event, it should also support the
  114. * resume event, to continue speaking the current utterance, if any. Note that a
  115. * stop event should also clear the paused state.
  116. * @type {!ChromeEvent}
  117. * @see https://developer.chrome.com/extensions/ttsEngine#event-onResume
  118. */
  119. chrome.ttsEngine.onResume;